Package org.apache.commons.math.distribution

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

@version $Revision: 920852 $ $Date: 2010-03-09 13:53:44 +0100 (mar. 09 mars 2010) $

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

   
    if(number>trails || number <0)
      throw new SSErrorXelException(SSError.NUM);
    else{
      DistributionFactory factory = DistributionFactory.newInstance();
      BinomialDistribution bd = factory.createBinomialDistribution(trails, p_s);
      if(isCumulative)
        return UtilFns.validateNumber(bd.cumulativeProbability(number));
      else
        return UtilFns.validateNumber(bd.probability(number));
    }
  }
View Full Code Here

TOP

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

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.