All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.expleague.commons.math.stat.impl.SampleDistribution Maven / Gradle / Ivy

Go to download

Utilities including math, charsequence based text processing, sequences etc.

There is a newer version: 1.4.9
Show newest version
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