Sign in to follow this  
phi

Convert X inputs into numerical output

Recommended Posts

Hi everyone, I may be overcomplicating things, but how would I go about taking X number of inputs and combining them all to create an 'output ID'? The key thing about the ID is that it should take all the inputs into account (preferably with weighting such as having X1 slightly more important than X2) and produce a number where number can be used to compare similarity. For example: A) Inputs 1,2,3 ---> <perform function> ---> 0123456 B) Inputs 1,2,4 ---> <perform function> ---> 0123457 C) Inputs 5,3,8 ---> <perform function> ---> 1354565 Notice A and B are similar, so the outputs are similar to each other than A/B and C. Thank you for any help [Edited by - phi on July 24, 2009 5:30:16 PM]

Share this post


Link to post
Share on other sites
Wow, thanks for the quick reply! The Hamming Distance seems like a good method of finding the 'distance' between the outputs, but how would I generate the outputs to use?

Share this post


Link to post
Share on other sites
That depends on what you're trying to do.

1) Do the ID's have to be unique? If no, then the problem becomes easier.

2) Do the number of inputs vary during runtime? If yes, the problem seems to get a little harder. Comparison would also become complicated. How would compare 2 different sized strings? Is "123" closer to "1234" or to "223"?

Share this post


Link to post
Share on other sites
Hi,
Thanks for the reply.

1) The ID's do not have to be unique (although it's preferable that fewer are to provide greater granularity)

2) For the time being, input sizes will be the same size for each input, but different from each input.
e.g:
Input 1 will always be 4 digits long
Input 2 will always be 6 digits long
Input 3 will always be 3 digits long
etc..

Share this post


Link to post
Share on other sites
Ahh, I think I misunderstood slightly, I thought all inputs were a single digit (or char).

My naive solution would be to build a string of fields, one for each input, seperated by a delimiter, and an extra field as a 'counter' that increased for inputs that were all the same. For example:

Inputs [1234],[654321],[987] ---> "1234.654321.987.0"
Inputs [5678],[123456],[789] ---> "5678.123456.789.0"
Inputs [1234],[654321],[987] ---> "1234.654321.987.1" <-- same as 1st input, increase counter
...

I'm sure there are more optimal solutions, such as using hash codes (a search should reveal lots of articles on hashing).

Also, I still feel like maybe I'm misunderstanding your problem (must be lack of sleep...)

Share this post


Link to post
Share on other sites
lol I may not have explained it properly, although I think you've got it. I initially had the same idea as you did where I could just literally append everything together, but I felt this may not work given the nature of the task.
Essentially what I'm trying to achieve is the ability to "encode" a certain state into a number. Similar states would have similar numbers. A state is something that is made up of various inputs (Time, Lives, Health etc..). To simplify this processing I'm going to convert all the inputs into numerical values.
However, things get complicated when a previous state is also taken into account.
E.G. A previous state acts as an input to the new state which means that a certain number will be produced even if all other inputs are the same.

I'll take a look at hashing. I need to ensure that the hash function doesn't generate a random number using artibtary salts as this would not allow for similarity between states.

Thanks again for the help.

Share this post


Link to post
Share on other sites


Quote:
Original post by phi
I'm going to convert all the inputs into numerical values.

If you are truly turning it into a numerical value, then you will need a type of varable that can store enough bits of info (for the 3 input 13-digit example you gave, a 32-bit integer wouldn't do). You would have to implement (or your language would have to) large/unlimited digit numeric types. This is assuming that you need to avoid collisions (occasionally different states have same ID)

Or just use a string "" of digits (potentially sacrificing memory and speed).

Or find a perfect hash function for your inputs.

Quote:

although I think you've got it
...
A previous state acts as an input to the new state which means that a certain number will be produced even if all other inputs are the same.


Nope, now I'm confused again :p Isn't that what the 3rd line of this
Quote:

Inputs [1234],[654321],[987] ---> "1234.654321.987.0"
Inputs [5678],[123456],[789] ---> "5678.123456.789.0"
Inputs [1234],[654321],[987] ---> "1234.654321.987.1" <-- same as 1st input, increase counter

did?

Also, I have to ask, what are trying to accomplish with all this? Perhaps there is an entirely different method that will provide a less complicated solution.


Share this post


Link to post
Share on other sites
Hi,
Sorry for the late reply, I was unable to access the internet (but I survived! :D). For the time being, ignore any of my constraints mentioned in my other posts.
What I'm trying to do is to have a large number of 'states' and compare their similarities to a given state. So for example, a state consists of 'Lives, Time Played and Level'(although there will be a few more factors besdies these three). Another state would consist of the same thing and so I'd like to compare their similarities.
The slightly more confusing bit comes into a chain of states. I'd like the next state in the chain to incorporate the information from the previous state. To clarify: (read in columns)
1)State X1 = 10,30,50 1)State Y1 = 30,40,10 State Z1 = 1,2,3
2)State Z1 = 32,43,56 2)State Z1 = 36,16,75

As you can see, State Z1 would normally be 1,2,3 if it was the initial state. However, when preceded by something else, it changes. This way, I can then compare a chain of states rather than individual ones. In case a chain to extremely long, I'd rather not iterate through each one and compare.

Hope that's a bit clearer (although it's quite late, so I may be confusing things further lol)

Thanks

Share this post


Link to post
Share on other sites
The solution to this kind of problems depends heavily on how you're going to use the data. So without any analogies or generalizations, what exactly do you hope to accomplish by converting these state combinations into values? If you're trying to rate players, there are easier ways to go about it :)

Share this post


Link to post
Share on other sites
Hi,
I'm trying to monitor user's habitual patterns in game and so I thought the best way to go about it is to try and compress any data into a number for each state. I'm trying to create an adaptive user interface so that it's context sensitive as well as customised to the user themselves. Therefore, if the user often accesses the "buy" menu after he walks into a village, I can decide whether to preload the 'buy' menu or automatically display it on screen. I'm hoping this would a less intrusive UI.
My original plan was to take all the factors (Location, Lives etc..) and try and convert them into a number. But maybe I'm going about this all wrong :/ ?

Share this post


Link to post
Share on other sites
Quote:
Original post by phi
...if the user often accesses the "buy" menu after he walks into a village, I can decide whether to preload the 'buy' menu or automatically display it on screen.
My original plan was to take all the factors (Location, Lives etc..) and try and convert them into a number. But maybe I'm going about this all wrong :/ ?

Yep, sounds like a good old case of overcomplification to me [grin] (I tend to have the same problem from time to time...) If you want to keep track of how often a user accesses a menu item, then just keep track of how many times a user accesses a menu item. And whatever other metrics you decide. This sounds to me like a simpler, more efficient way of approaching the problem, to me.

Share this post


Link to post
Share on other sites
Ah, hopefully I haven't waste my time! lol. I'm looking at around 1000-2000 potential 'shops' and also would like to take into account past actions. The transition matrix would be huge if I had Village --> Shop, House --> Shop, Shop --> Forest etc.. (i.e. from every potential location to every other potential location). Would there be a way of being able to 'backtrack' through the past N states?
My plan was to try and merge all information (including past locations) into one number so that it would be efficient to calculate any methods. From this number, I would be able to put it into a reverse function and derive one state previously and so one.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this