private double cumulativeProbability(double x) { try { NormalDistribution normDist = new NormalDistribution(); return normDist.cumulativeProbability(x); } catch (IllegalArgumentException ex) { return Double.NaN; } }
@Override public void reseedRandomGenerator(long seed) { realDist.reseedRandomGenerator(seed); }
public double [] pValues(){ double [] res = zValues(); RealDistribution rd = _dispersionEstimated?new TDistribution(_training_metrics.residual_degrees_of_freedom()):new NormalDistribution(); for(int i = 0; i < res.length; ++i) res[i] = 2*rd.cumulativeProbability(-Math.abs(res[i])); return res; } double[][] _global_beta_multinomial;
private Object generateSingleRowValue() { Object ret = null; ValueType type = schema.getType(); if (distribution instanceof AbstractIntegerDistribution) { ret = ((AbstractIntegerDistribution) distribution).sample(); } else if (distribution instanceof AbstractRealDistribution) { ret = ((AbstractRealDistribution) distribution).sample(); } else if (distribution instanceof EnumeratedDistribution) { ret = ((EnumeratedDistribution) distribution).sample(); } ret = convertType(ret, type); return ret; }
/** * {@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 number of successes {@code r} and probability of success {@code p}, * the mean is {@code r * (1 - p) / p}. */ public double getNumericalMean() { final double p = getProbabilityOfSuccess(); final double r = getNumberOfSuccesses(); return (r * (1 - p)) / p; }
@Override public int sample() { double randomVal = realDist.sample(); long longVal = Math.round(randomVal); return (int) longVal; } }
/** * {@inheritDoc} */ @Override public int sample() { if (sampler == null) { sampler = new ZipfRejectionInversionSampler(numberOfElements, exponent); } return sampler.sample(random); }
public boolean reset() { if (seed == null) { return false; } normalDistribution.reseedRandomGenerator(seed); return true; }
/** * {@inheritDoc} * * For mean parameter {@code mu}, the mean is {@code mu}. */ public double getNumericalMean() { return getMean(); }
/** * {@inheritDoc} * * For mean parameter {@code k}, the mean is {@code k}. */ public double getNumericalMean() { return getMean(); }
/** * {@inheritDoc} * * @return {@code 2 * k}, where {@code k} is the number of degrees of freedom. */ public double getNumericalVariance() { return 2 * getDegreesOfFreedom(); }
/** * {@inheritDoc} * * For mean parameter {@code p}, the variance is {@code p}. */ public double getNumericalVariance() { return getMean(); }
/** {@inheritDoc} */ public double value(final double x) { return cumulativeProbability(x) - p; } };
/** {@inheritDoc} **/ @Override public double logDensity(double x) { return gamma.logDensity(x); }
/** * For a random variable {@code X} whose values are distributed according to * this distribution, this method returns {@code P(X = x)}. In other words, * this method represents the probability mass function (PMF) for the * distribution. * * @param x the point at which the PMF is evaluated * @return the value of the probability mass function at point {@code x} */ public double density(final double x) { return probability(x); }
/** * 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 number of successes {@code r} and probability of success {@code p}, * the variance is {@code r * (1 - p) / p^2}. */ public double getNumericalVariance() { final double p = getProbabilityOfSuccess(); final double r = getNumberOfSuccesses(); return r * (1 - p) / (p * p); }
/** * {@inheritDoc} * * For mean parameter {@code k}, the variance is {@code k^2}. */ public double getNumericalVariance() { final double m = getMean(); return m * m; }