Weight Computation

The weight calculation takes decay type into account, whether this decay is linear or half life.

Linear

This is decay type is when quality declines linearly over a set period of time. For example, if decay is defined as ten months, in five months the weight becomes half of the initial quality. In ten months the weight becomes zero.

If LINEAR,

if ageOfDataInMillis > decayPeriodInMilliscomputedWeight = 0elsecomputedWeight = Math.round(given Weight * (1 - ((float) ageOfDataInMillis / (float) decayPeriodInMillis)))]

Half Life

With this decay type, the quality never becomes zero. It gets lower as more intervals expire. For example, if the decay has a half life of six months and the initial weight is 70, in six months the weight becomes 35. In another six months, the weight becomes 17, and so on.

If HALFLIFE,

[float n = ((float) ageOfDataInMillis / (float) decayPeriodInMillis);computedWeight = Math.round( (float)(given Weight / (Math.pow(2, n))))]

The following is how Precedence is applied:
  • If the old weight > the new weight, it reverts to the old data.
  • If the old weight <= the new weight, it continues with the new data.