var minCount = 10; // Used as 0, anything below 10 uses will be ignored
User hasMany Attributes
Attribute (id, value, count, worth)
// Count - number of users who associate with this attribute
// Worth - float 0.1 (or a better non-zero number?) to 1
An attribute with count of minCount has worth 1. The attribute(s) with the highest count has the lowest possible worth. The lesser used attributes are worth more - lower count -> higher worth.
The difference in worth should be exponential:
I'll be using php for now, but psuedo code is equally acceptable - I'd rather just understand how to do it.
So what's the problem?
Use the following simple formula:
currentWorth = exp(minCount / currentCount - 1)
where:
exp
- exponent of e
;
currentCount
- current attribute's count;
minCount
- least attribute's count.
First consider formula without exponent application:
currentWorth = minCount / currentCount
For attribute having minimal count (currentCount = minCount):
currentWorth = minCount / minCount = 1
For attributes having any other count (obviously greater than minCount):
(currentWorth = minCount / currentCount) < 1
Now let's apply exponential law:
currentWorth = exp(minCount / currentCount - 1)
For attribute having minimal count (currentCount = minCount):
currentWorth = exp(minCount / minCount - 1) = exp(1 - 1) = exp(0) = 1
For attributes having any other count (currentCount > minCount):
currentWorth = exp(minCount / currentCount - 1)
Assuming:
t = 1 - minCount / currentCount > 0
We'll have:
(currentWorth = exp(-t) = 1 / exp(t)) < 1