/** Returns the Bin that's the mode of the distribution (i.e. the largest bin). */ private Bin<K> getModeBin() { Bin<K> modeBin = null; for (final Bin<K> bin : values()) { if (modeBin == null || modeBin.value < bin.value) { modeBin = bin; } } return modeBin; }
public double getCount() { double count = 0; for (final Bin<K> bin : values()) { count += bin.value; } return count; }
/** Returns the Bin that's the mode of the distribution (i.e. the largest bin). */ private Bin getModeBin() { Bin modeBin = null; for (final Bin bin : values()) { if (modeBin == null || modeBin.value < bin.value) { modeBin = bin; } } return modeBin; }
public double getCount() { double count = 0; for (final Bin bin : values()) { count += bin.value; } return count; }
/** Returns the Bin that's the mode of the distribution (i.e. the largest bin). */ private Bin<K> getModeBin() { Bin<K> modeBin = null; for (final Bin<K> bin : values()) { if (modeBin == null || modeBin.value < bin.value) { modeBin = bin; } } return modeBin; }
public double getCount() { double count = 0; for (final Bin<K> bin : values()) { count += bin.value; } return count; }
/** Gets the geometric mean of the distribution. */ public double getGeometricMean() { double total = 0; double count = 0; for (final Bin<K> bin : values()) { total += bin.value * log(bin.getIdValue()); count += bin.value; } return exp(total / count); }
/** * Returns the sum of the number of entries in each bin. */ public double getSumOfValues() { double total = 0; for (final Bin bin : values()) { total += bin.getValue(); } return total; }
/** Gets the geometric mean of the distribution. */ public double getGeometricMean() { double total = 0; double count = 0; for (final Bin bin : values()) { total += bin.value * log(bin.getIdValue()); count += bin.value; } return exp(total / count); }
/** Gets the geometric mean of the distribution. */ public double getGeometricMean() { double total = 0; double count = 0; for (final Bin<K> bin : values()) { total += bin.value * log(bin.getIdValue()); count += bin.value; } return exp(total / count); }
private double effectiveNumberOfBases(Histogram<?> observations) { double totalObservations = observations.getSumOfValues(); // Convert to log base 4 so that the entropy is now a measure // of the effective number of DNA bases. If we used log(2.0) // our result would be in bits. double entropyBaseE = observations.values().stream().collect(Collectors.summingDouble( v -> {double p = v.getValue() / totalObservations; return -p * Math.log(p);})); return entropyBaseE / MathUtil.LOG_4_BASE_E; } }
private double effectiveNumberOfBases(Histogram<?> observations) { double totalObservations = observations.getSumOfValues(); // Convert to log base 4 so that the entropy is now a measure // of the effective number of DNA bases. If we used log(2.0) // our result would be in bits. double entropyBaseE = observations.values().stream().collect(Collectors.summingDouble( v -> {double p = v.getValue() / totalObservations; return -p * Math.log(p);})); return entropyBaseE / MathUtil.LOG_4_BASE_E; } }
public double getStandardDeviation() { final double mean = getMean(); double count = 0; double total = 0; for (final Bin bin : values()) { final double localCount = bin.getValue(); final double value = bin.getIdValue(); count += localCount; total += localCount * pow(value - mean, 2); } return Math.sqrt(total / (count-1)); }
/** * Returns the sum of the products of the histgram bin ids and the number of entries in each bin. */ public double getSum() { double total = 0; for (final Bin bin : values()) { total += bin.getValue() * bin.getIdValue(); } return total; }
/** Gets the median absolute deviation of the distribution. */ public double getMedianAbsoluteDeviation() { final double median = getMedian(); final Histogram<Double> deviations = new Histogram<>(); for (final Bin<K> bin : values()) { final double dev = abs(bin.getIdValue() - median); deviations.increment(dev, bin.getValue()); } return deviations.getMedian(); }
/** Gets the median absolute deviation of the distribution. */ public double getMedianAbsoluteDeviation() { final double median = getMedian(); final Histogram<Double> deviations = new Histogram<>(); for (final Bin<K> bin : values()) { final double dev = abs(bin.getIdValue() - median); deviations.increment(dev, bin.getValue()); } return deviations.getMedian(); }
/** Gets the median absolute deviation of the distribution. */ public double getMedianAbsoluteDeviation() { final double median = getMedian(); final Histogram<Double> deviations = new Histogram<Double>(); for (final Bin bin : values()) { final double dev = abs(bin.getIdValue() - median); deviations.increment(dev, bin.getValue()); } return deviations.getMedian(); }