Package org.apache.commons.math.distribution

Examples of org.apache.commons.math.distribution.BinomialDistributionImpl


//  public static double qpois(double p, double lambda, boolean lowerTail, boolean logP)  {
//    return q(new PoissonDistributionImpl(lambda), p, lowerTail, logP);
//  }
  @DataParallel @Internal
  public static double dbinom(@Recycle double x, @Recycle int size, @Recycle double prob, boolean log) {
    return d(new BinomialDistributionImpl(size, prob), x, log);
  }
View Full Code Here


    return Binom.dnbinom_mu(x, size, mu, log);
  }

  @DataParallel @Internal
  public static double pbinom(@Recycle double x, @Recycle int size, @Recycle double prob, boolean lowerTail, boolean logP) {
    return p(new BinomialDistributionImpl(size, prob), x, lowerTail, logP);
  }
View Full Code Here

    }
  }

  @DataParallel @Internal
  public static double qbinom(@Recycle double p, @Recycle int size, @Recycle double prob, boolean lowerTail, boolean logP) {
    return q(new BinomialDistributionImpl(size, prob), p, lowerTail, logP) + 1;
  }
View Full Code Here

     * @return random value sampled from the Binomial(numberOfTrials, probabilityOfSuccess) distribution
     * @throws MathException if an error occurs generating the random value
     * @since 2.2
     */
    public int nextBinomial(int numberOfTrials, double probabilityOfSuccess) throws MathException {
        return nextInversionDeviate(new BinomialDistributionImpl(numberOfTrials, probabilityOfSuccess));
    }
View Full Code Here

import uk.ac.cam.ch.wwmm.ptclib.xml.XOMTools;

public class ReactCollocations {

  public static double binomialProbEqualGreater(int trials, int success, double prob) throws MathException {
    BinomialDistribution bd = new BinomialDistributionImpl(trials, prob);
    double score = 0;
    for(int i=success;i<=trials;i++) {
      score += bd.probability(i);
    }
    //double score = bd.cumulativeProbability(success-1);
    System.out.println("bd:\t" + trials + "\t" + success + "\t" + prob + "\t" + (1.0-score) + "\t" + bd.cumulativeProbability(success-1));
    return 1.0 - score;
  }
View Full Code Here

   * @param args
   */
  public static void main(String[] args) throws Exception {
    if(true) {
      long time = System.currentTimeMillis();
      BinomialDistribution bd = new BinomialDistributionImpl(10000000, 0.5);
      double d = bd.cumulativeProbability(3456789);
      //for(int i=-1;i<=100000;i++) {
      //  double d = bd.cumulativeProbability(i);
      //  //System.out.println(i + "\t" + bd.cumulativeProbability(i) + "\t" + (1.0 - bd.cumulativeProbability(i)));
      //}
      System.out.println(System.currentTimeMillis() - time);
View Full Code Here

        BinomialDistributionTest testInstance = new BinomialDistributionTest("");
        int[] densityPoints = testInstance.makeDensityTestPoints();
        double[] densityValues = testInstance.makeDensityTestValues();
        int sampleSize = 1000;
        int length = TestUtils.eliminateZeroMassPoints(densityPoints, densityValues);
        BinomialDistributionImpl distribution = (BinomialDistributionImpl) testInstance.makeDistribution();
        double[] expectedCounts = new double[length];
        long[] observedCounts = new long[length];
        for (int i = 0; i < length; i++) {
            expectedCounts[i] = sampleSize * densityValues[i];
        }
        randomData.reSeed(1000);
        for (int i = 0; i < sampleSize; i++) {
          int value = randomData.nextBinomial(distribution.getNumberOfTrials(),
                  distribution.getProbabilityOfSuccess());
          for (int j = 0; j < length; j++) {
              if (value == densityPoints[j]) {
                  observedCounts[j]++;
              }
          }
View Full Code Here

TOP

Related Classes of org.apache.commons.math.distribution.BinomialDistributionImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.