/** * {@inheritDoc} * * For population size {@code N}, number of successes {@code m}, and sample * size {@code n}, the mean is {@code n * m / N}. */ public double getNumericalMean() { return getSampleSize() * (getNumberOfSuccesses() / (double) getPopulationSize()); }
/** * Used by {@link #getNumericalVariance()}. * * @return the variance of this distribution */ protected double calculateNumericalVariance() { final double N = getPopulationSize(); final double m = getNumberOfSuccesses(); final double n = getSampleSize(); return (n * m * (N - n) * (N - m)) / (N * N * (N - 1)); }
/** * {@inheritDoc} * * For population size {@code N}, number of successes {@code m}, and sample * size {@code n}, the lower bound of the support is * {@code max(0, n + m - N)}. * * @return lower bound of the support */ public int getSupportLowerBound() { return FastMath.max(0, getSampleSize() + getNumberOfSuccesses() - getPopulationSize()); }
/** * Used by {@link #getNumericalVariance()}. * * @return the variance of this distribution */ protected double calculateNumericalVariance() { final double N = getPopulationSize(); final double m = getNumberOfSuccesses(); final double n = getSampleSize(); return (n * m * (N - n) * (N - m)) / (N * N * (N - 1)); }
/** * {@inheritDoc} * * For population size {@code N}, number of successes {@code m}, and sample * size {@code n}, the lower bound of the support is * {@code max(0, n + m - N)}. * * @return lower bound of the support */ public int getSupportLowerBound() { return Math.max(0, getSampleSize() + getNumberOfSuccesses() - getPopulationSize()); }
/** * Used by {@link #getNumericalVariance()}. * * @return the variance of this distribution */ protected double calculateNumericalVariance() { final double N = getPopulationSize(); final double m = getNumberOfSuccesses(); final double n = getSampleSize(); return (n * m * (N - n) * (N - m)) / (N * N * (N - 1)); }
/** * {@inheritDoc} * * For population size {@code N}, number of successes {@code m}, and sample * size {@code n}, the mean is {@code n * m / N}. */ public double getNumericalMean() { return getSampleSize() * (getNumberOfSuccesses() / (double) getPopulationSize()); }
/** * {@inheritDoc} * * For population size {@code N}, number of successes {@code m}, and sample * size {@code n}, the mean is {@code n * m / N}. */ public double getNumericalMean() { return getSampleSize() * (getNumberOfSuccesses() / (double) getPopulationSize()); }
/** * {@inheritDoc} * * For population size {@code N}, number of successes {@code m}, and sample * size {@code n}, the lower bound of the support is * {@code max(0, n + m - N)}. * * @return lower bound of the support */ public int getSupportLowerBound() { return FastMath.max(0, getSampleSize() + getNumberOfSuccesses() - getPopulationSize()); }
/** * @param param * population size * @param param2 * number of successes * @param param3 * sample size * @return hypergeometric distribution */ protected HypergeometricDistribution getHypergeometricDistribution( int param, int param2, int param3) { if (hypergeometric == null || hypergeometric.getNumberOfSuccesses() != param2 || hypergeometric.getPopulationSize() != param || hypergeometric.getSampleSize() != param3) { hypergeometric = new HypergeometricDistribution(param, param2, param3); } return hypergeometric; }
HypergeometricDistribution ha = (HypergeometricDistribution) a; HypergeometricDistribution hb = (HypergeometricDistribution) b; return ha.getPopulationSize() == hb.getPopulationSize() && ha.getNumberOfSuccesses() == hb.getNumberOfSuccesses() && ha.getSampleSize() == hb.getSampleSize();
HypergeometricDistribution ha = (HypergeometricDistribution) a; HypergeometricDistribution hb = (HypergeometricDistribution) b; return ha.getPopulationSize() == hb.getPopulationSize() && ha.getNumberOfSuccesses() == hb.getNumberOfSuccesses() && ha.getSampleSize() == hb.getSampleSize();
} else if (c == HypergeometricDistribution.class) { HypergeometricDistribution hd = (HypergeometricDistribution) d; j.writeNumberField("populationSize", hd.getPopulationSize()); j.writeNumberField("numberOfSuccesses", hd.getNumberOfSuccesses()); j.writeNumberField("sampleSize", hd.getSampleSize());
} else if (c == HypergeometricDistribution.class) { HypergeometricDistribution hd = (HypergeometricDistribution) d; j.writeNumberField("populationSize", hd.getPopulationSize()); j.writeNumberField("numberOfSuccesses", hd.getNumberOfSuccesses()); j.writeNumberField("sampleSize", hd.getSampleSize());