com.expleague.commons.math.stat.impl.SampleDistribution Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons Show documentation
Show all versions of commons Show documentation
Utilities including math, charsequence based text processing, sequences etc.
package com.expleague.commons.math.stat.impl;
import com.expleague.commons.math.stat.Distribution;
import gnu.trove.map.hash.TObjectIntHashMap;
/**
* @author vp
*/
public class SampleDistribution implements Distribution {
protected TObjectIntHashMap samples;
protected double totalCount;
public SampleDistribution() {
samples = new TObjectIntHashMap();
}
public void update(final T observation) {
samples.adjustOrPutValue(observation, 1, 1);
totalCount++;
}
@Override
public double getProbability(final T observation) {
return samples.get(observation) / totalCount;
}
@Override
public Object[] getUniversum() {
return samples.keys();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy