Skip to main content
GameDev.net gamedev.net
🔒 Locked

Algorithm for detecting scattered-ness

Started by theMadHatter Apr 6, 2011 at 10:43 PM 10 replies 3.2k views
Original Post
theMadHatter
theMadHatter
Hey,

I'm looking for an algorithm or suggestion of algorithms that can detect the scattered-ness of a data set. I'm not sure exactly how to explain it. Let's say I have two lists of numbers and I want to detect which one seems to be more random; which one seems to be more scattered. Is there any mathematical formula that I could apply?

Thanks
ddn3
ddn3
You can measure it the way statisticians do, they use various methods but a common one is standard deviation..

Standard Deviation Wiki

-ddn
theMadHatter
theMadHatter
Ah, yes of course. My mind is too scattered right now.
Matias Goldberg
Matias Goldberg
Just wanted to say scattering != randomness.

A sequence like "10 5654 78 2 2 2 1056 687 321 1 1 " May be completely random (ok, I typed them, so they probably aren't) even though there are three '2' in a row and two '1' in a row.

Thinking randomness means things shouldn't repeat in a long time in a sequence is a common miss-conception of what "true" randomness is.

theMadHatter
theMadHatter
Good point. I understand. I suppose the scattering is the optimal word here.
Emergent
Emergent
My bet is on variance/standard deviation as ddn3 mentioned, but another quantity that might be relevant is Shannon Entropy.
alvaro
alvaro
If you give us an example of dataset whose "scattered-ness" you want to measure, we can try to be much more informative. Depending on the situation, you may want the standard deviation, or perhaps a measure of whether a distribution is too clustered or not clustered enough (compared to a Poisson distribution)... Whatever it is, I am sure we can help. So, what does your data look like?
theMadHatter
theMadHatter
Alright. So the data is for a mock dating website. Basically the user is given a list of attributes and they rate the individual as a whole on a scale from 1 to 10. So basically at the end I will have a bunch of attributes in different categories (e.g. blonde, brunette, likes hiking, likes computer games, etc.). So I need to figure which attributes the user cares most about. I'm thinking of going at this by detecting which ones have the lowest degree of scattering. Does this help?
alvaro
alvaro
Sorry, I don't understand. I don't know if "user" and "individual" refer to the same thing or not. The users rate the individuals? And which of them has a list of attributes? Are you trying to predict how much a user will like an individual based on previous ratings? Perhaps you can explain in a little more detail, and a bit more formally...
theMadHatter
theMadHatter
Certainly.
The user rates a series of potential matches. Each match has a list of attributes. When the user gives the potential match a rating each of the attributes held by this individual (the potential match) is used as an index into a map with a list of ratings. So each attribute has a list of how it has been rated in the past. So yes, I am trying to predict how much a user will like a potential match based on the previous ratings of their attributes.
So basically right now I am trying to devise a way to detect which of the attributes are more important to the user doing the rating. I figure if I figure out with ones are consistent in how they are ranked is a good start (the ones with inconsistent ratings probably aren't that important to the user I'd like to guess). Does this sound appropriate? Would standard deviation be a good way to test this?
Emergent
Emergent
This is for a dating sim?

There are two ways you can do this. One is to rely on having users "rate" potential matches on a numerical scale. Another is pairwise comparisons -- that is, answers to questions of the form, "which of these two matches do you find more attractive?" This second approach is also called a two-alternative forced choice (2AFC) experiment. There's also 3AFC (also includes "they're the same" as an acceptable answer) and 4AFC (also includes "they're totally different; I have no way to compare them.").

I've actually looked at this second approach a fair bit. There are some nice ways to use support vector machines to tackle these problems; see e.g. Herbrich '99. (Actually, Herbrich assumes an ordinal scale -- sort of closer to numerical ranking -- but the spirit of his approach is very close to 2AFC).

If you want to go with the first approach -- numerical scores -- you have a number of options as well. The simplest of these is least-squares, which you might want to consider. Here's how it'd work:

A person has rated N people. We represent these people as points x1,...,xN in a high-dimensional space; the coordinates are the values of their various attributes. These people have been given ratings r1,...,rN. Now, what you want to find is an N-dimensional weight vector w and scalar bias b such that

+ b = r1
...
+ b = rN

where <.,.> represents the inner (a.k.a. "dot") product. Letting z = (w, b) and r=(r1,...,rN), you can summarize this system of equations,

A z = r

for a particular matrix A. To construct this matrix, first build a matrix whose rows are x1^T,...,xN^T; then append an extra column of ones. Now, this system of equations is overdetermined, so you won't find a z that satisfies them; you can, however, find one that has the least error, in a sum-of-squares sense. This is the solution to the "normal equations,"

A^T A z = A^T r .

With a nice linear algebra library (I like Eigen in C++), you can solve this in various ways; I'd suggest solving them with Eigen's QR factorization module (for small problems) or a conjugate gradient solver (for large problems). With each of these methods, you (1) never really form the matrix A^T A (called the Gramian) explicitly, and (2) can also find a solution when the system is underdetermined. These are my reasons for recommending them.

The weight vector w that you get will implicitly tell you which attributes are good, which are bad, and how important the various ones are. Very good attributes will receive large positive weights, very bad attributes will receive large-in-absolute-value negative weights, and unimportant ones will have weights close to zero.
theMadHatter
theMadHatter
Wow, great response. I will definitely attempt a shot at this.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.