public final class IdMeanAccumulator extends Object
Constructor and Description |
---|
IdMeanAccumulator() |
Modifier and Type | Method and Description |
---|---|
ImmutableSparseVector |
computeIdMeans(double offset,
double damping)
Compute the means for each ID.
|
double |
globalMean()
Get the global mean.
|
ImmutableSparseVector |
idMeanOffsets()
Compute offsets from the global mean for each ID.
|
ImmutableSparseVector |
idMeanOffsets(double damping)
Compute mean offsets for each item.
|
ImmutableSparseVector |
idMeans()
Get the per-ID means.
|
void |
put(long id,
double val)
Accumulate a value with an ID.
|
public void put(long id, double val)
id
- The ID.val
- The value.public double globalMean()
public ImmutableSparseVector idMeans()
computeIdMeans(0, 0)
.computeIdMeans(double, double)
public ImmutableSparseVector computeIdMeans(double offset, double damping)
The prior (assumed value for additional values) is always 0 in the output domain. If \(y>0\), then the values are offset first, and then damped towards 0. This method does not yet support damping towards some other value; if you need actual damped means, where each is damped towards the global mean, add the global mean to the resulting vector.
offset
- An offset to subtract from each value prior to averaging.damping
- The damping term (see idMeanOffsets(double)
).public ImmutableSparseVector idMeanOffsets(double damping)
computeIdMeans(globalMean(), damping)
.damping
- The damping term.computeIdMeans(double, double)
public ImmutableSparseVector idMeanOffsets()