/** * Returns the upper bound of the support for the distribution. * * The upper bound of the support is the number of trials. * * @return upper bound of the support (equal to number of trials) * @since 2.2 */ public int getSupportUpperBound() { return getNumberOfTrials(); }
/** * Access the domain value upper bound, based on <code>p</code>, used to * bracket a PDF root. * * @param p the desired probability for the critical value * @return domain value upper bound, i.e. * P(X < <i>upper bound</i>) > <code>p</code> */ protected int getDomainUpperBound(double p) { return getNumberOfTrials(); }
/** * Returns the mean. * * For <code>n</code> number of trials and * probability parameter <code>p</code>, the mean is * <code>n * p</code> * * @return the mean * @since 2.2 */ public double getNumericalMean() { return (double)getNumberOfTrials() * getProbabilityOfSuccess(); }
/** * Returns the variance. * * For <code>n</code> number of trials and * probability parameter <code>p</code>, the variance is * <code>n * p * (1 - p)</code> * * @return the variance * @since 2.2 */ public double getNumericalVariance() { final double p = getProbabilityOfSuccess(); return (double)getNumberOfTrials() * p * (1 - p); } }
/** * For this disbution, X, this method returns P(X = x). * * @param x the value at which the PMF is evaluated. * @return PMF for this distribution. */ public double probability(int x) { double ret; if (x < 0 || x > getNumberOfTrials()) { ret = 0.0; } else { ret = MathUtils.binomialCoefficientDouble( getNumberOfTrials(), x) * Math.pow(getProbabilityOfSuccess(), x) * Math.pow(1.0 - getProbabilityOfSuccess(), getNumberOfTrials() - x); } return ret; }
/** * For this distribution, X, this method returns P(X ≤ x). * @param x the value at which the PDF is evaluated. * @return PDF for this distribution. * @throws MathException if the cumulative probability can not be * computed due to convergence or other numerical errors. */ public double cumulativeProbability(int x) throws MathException { double ret; if (x < 0) { ret = 0.0; } else if (x >= getNumberOfTrials()) { ret = 1.0; } else { ret = 1.0 - Beta.regularizedBeta( getProbabilityOfSuccess(), x + 1.0, getNumberOfTrials() - x); } return ret; }