View Javadoc

    1   package baseCode.math.distribution;
    2
    3   import cern.jet.stat.Probability;
    4
    5   /***
    6    * <hr>
    7    * <p>
    8    * Copyright (c) 2004 Columbia University
    9    *
    10   * @author pavlidis
    11   * @version $Id: NormalProbabilityComputer.java,v 1.1 2004/12/31 01:14:48 pavlidis Exp $
    12   */
    13  public class NormalProbabilityComputer implements ProbabilityComputer {
    14
    15     double variance;
    16     double mean;
    17
    18     /***
    19      * @param variance
    20      * @param mean
    21      */
    22     public NormalProbabilityComputer( double variance, double mean ) {
    23        super();
    24        this.variance = variance;
    25
    26        if (variance < 0) {
    27           throw new IllegalArgumentException("Variance must be non-negative");
    28        }
    29
    30        this.mean = mean;
    31     }
    32
    33     /*
    34      * (non-Javadoc)
    35      *
    36      * @see baseCode.math.ProbabilityComputer#probability(double)
    37      */
    38     public double probability( double value ) {
    39        return 1.0 - Probability.normal( mean, variance, value );
    40     }
    41
    42     public double probability( double value, boolean upperTail ) {
    43        if ( upperTail ) {
    44           return probability( value );
    45        }
    46
    47        return Probability.normal( mean, variance, value );
    48
    49     }
    50
    51  }