ProbDemo.java


Below is the syntax highlighted version of ProbDemo.java from §9.7 Optimization.



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

import drasys.or.prob.*;

public class ProbDemo {

    public static void main(String[] args) { 

        // normal cdf and inverse cdf
        NormalDistribution normal = new NormalDistribution(0, 1);
        StdOut.println(normal.cdf(1.9605064392089844));
        StdOut.println(normal.inverseCdf(0.975));
        StdOut.println();

        // students t distribution cdf and inverse cdf
        StudentsTDistribution students = new StudentsTDistribution(25 - 1);
        StdOut.println(students.cdf(2.0638981368392706));
        StdOut.println(students.inverseCdf(0.975));
        StdOut.println();

        // incomplete beta function
        IncompleteBeta y = new IncompleteBeta(2, 3);
        StdOut.println(y.function(0.3));
        StdOut.println();

        // chi-square distribution with 10 degrees of freedom
        ChiSquareDistribution z = new ChiSquareDistribution(10);
        StdOut.println(z.cdf(18.307037535123527));
        StdOut.println(z.inverseCdf(0.95));
        StdOut.println();
    }

}


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