ProbDemo.java


Below is the syntax highlighted version of ProbDemo.java from §9.8 Data Analysis.



/******************************************************************************
 *  Compilation:  javac -classpath .:or124.jar ProbDemo.java
 *  Execution:    java -classpath .:or124.jar ProbDemo
 *
 *  Illustrate how to use OR-Objects stat package for generating
 *  random numbers from various distributions.
 *
 *  Reference: http://opsresearch.com/OR-Objects/api/
 *  Download:  http://opsresearch.com/cgi-bin/freeware.cgi/or124.jar
 *
 ******************************************************************************/

import drasys.or.prob.BinomialDistribution;
import drasys.or.prob.GammaDistribution;

public class ProbDemo {

    public static void main(String[] args) { 

        // gamma distribution
        GammaDistribution x = new GammaDistribution(2, 3);
        StdOut.println(x.getRandomScaler());

        // bionomial distribution
        BinomialDistribution y = new BinomialDistribution(0.1, 100);
        StdOut.println(y.getRandomVector(5));
    }

}


Copyright © 2000–2017, Robert Sedgewick and Kevin Wayne.
Last updated: Fri Oct 20 14:12:12 EDT 2017.