tags:

views:

123

answers:

4

How can I calculate values between 0 and 1 from values between 0 and n. E.g. I have items with "click count" and want to get "importance" (a float between 0 and 1) from that.

My attempt: importance = 1-1/count

gives bad results, since the values don't distribute well…

+9  A: 

I'm not sure what you mean by "don't distribute well". If you want to normalize a value between 0 and n to between 0 and 1, just divide by n.

Adam Wright
+3  A: 

just divide by n

Chris Card
A: 

How about count/n?

Kathy Van Stone
+3  A: 

Also not sure what you mean...

If you are looking for a linear distribution between 0 and 1, you need to know the maximum value of n. This will be transformed to 1.

importance = thisCount / maxCount;
Stefan Steinegger
Depending on what your counts are like, and whether this is for ordering or weighting, you might want to take a log too.
Jefromi