/** * Computes the CDF value for the given PMF for the input. That is, * the value of P=CDF(input)=sum(PMF(x<=input)). * @param input * Input to compute the CDF of. * @param distribution * Distribution to consider. * @return * CDF value of the distirbution for the given input */ public static double computeCumulativeValue( final int input, final ClosedFormDiscreteUnivariateDistribution<? super Integer> distribution ) { int minx = distribution.getMinSupport().intValue(); ProbabilityMassFunction<? super Integer> pmf = distribution.getProbabilityFunction(); double sum = 0.0; for( int x = minx; x <= input; x++ ) { sum += pmf.evaluate(x); } return sum; }
/** * Computes the CDF value for the given PMF for the input. That is, * the value of P=CDF(input)=sum(PMF(x<=input)). * @param input * Input to compute the CDF of. * @param distribution * Distribution to consider. * @return * CDF value of the distirbution for the given input */ public static double computeCumulativeValue( final int input, final ClosedFormDiscreteUnivariateDistribution<? super Integer> distribution ) { int minx = distribution.getMinSupport().intValue(); ProbabilityMassFunction<? super Integer> pmf = distribution.getProbabilityFunction(); double sum = 0.0; for( int x = minx; x <= input; x++ ) { sum += pmf.evaluate(x); } return sum; }
/** * Computes the CDF value for the given PMF for the input. That is, * the value of P=CDF(input)=sum(PMF(x<=input)). * @param input * Input to compute the CDF of. * @param distribution * Distribution to consider. * @return * CDF value of the distirbution for the given input */ public static double computeCumulativeValue( final int input, final ClosedFormDiscreteUnivariateDistribution<? super Integer> distribution ) { int minx = distribution.getMinSupport().intValue(); ProbabilityMassFunction<? super Integer> pmf = distribution.getProbabilityFunction(); double sum = 0.0; for( int x = minx; x <= input; x++ ) { sum += pmf.evaluate(x); } return sum; }