GaussianPDF.java


Below is the syntax highlighted version of GaussianPDF.java from §3.3 Designing Data Types.


/******************************************************************************
 *  Compilation:  javac GaussianPDF.java
 *  Execution:
 *
 *  A function that implements the Function interface.
 *
 ******************************************************************************/

public class GaussianPDF implements Function {
    public double evaluate(double x) {
        return Math.exp(-x*x/2) / Math.sqrt(2 * Math.PI);
    }
}


Copyright © 2000–2022, Robert Sedgewick and Kevin Wayne.
Last updated: Thu Aug 11 10:25:47 EDT 2022.