Clover coverage report - baseCode - 0.2.5
Coverage timestamp: Tue Apr 12 2005 11:31:58 EDT
file stats: LOC: 67   Methods: 4
NCLOC: 27   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
UniformProbabilityComputer.java 41.7% 52.9% 75% 51.5%
coverage coverage
 1   
 package baseCode.math.distribution;
 2   
 
 3   
 /**
 4   
  * Generate probabilities from the uniform distribution.
 5   
  * <hr>
 6   
  * <p>
 7   
  * Copyright (c) 2004 Columbia University
 8   
  * 
 9   
  * @author pavlidis
 10   
  * @version $Id: UniformProbabilityComputer.java,v 1.1 2004/12/31 01:14:48 pavlidis Exp $
 11   
  */
 12   
 public class UniformProbabilityComputer implements ProbabilityComputer {
 13   
 
 14   
    double min = 0;
 15   
    double max = 1;
 16   
 
 17   
    /**
 18   
     * Create a UniformProbabilityComputer where the density is defined over the unit inteval [0,1].
 19   
     */
 20  1
    public UniformProbabilityComputer() {
 21  1
       this( 0, 1 );
 22   
    }
 23   
 
 24   
    /**
 25   
     * Create a UniformProbabilityComputer where the density is defined over the interval given
 26   
     * 
 27   
     * @param min
 28   
     * @param max
 29   
     */
 30  1
    public UniformProbabilityComputer( double min, double max ) {
 31  1
       if ( max <= min ) {
 32  0
          throw new IllegalArgumentException( "Max must be higher than min" );
 33   
       }
 34  1
       this.min = min;
 35  1
       this.max = max;
 36   
    }
 37   
 
 38   
    /*
 39   
     * (non-Javadoc)
 40   
     * 
 41   
     * @see baseCode.math.ProbabilityComputer#probability(double)
 42   
     */
 43  10
    public double probability( double x ) {
 44  4
       if ( x < min ) return 0;
 45  2
       if ( x > max ) return 1;
 46  4
       return ( x - min ) / ( max - min );
 47   
    }
 48   
 
 49   
    /*
 50   
     * (non-Javadoc)
 51   
     * 
 52   
     * @see baseCode.math.ProbabilityComputer#probability(double, boolean)
 53   
     */
 54  0
    public double probability( double x, boolean upperTail ) {
 55   
 
 56  0
       if ( !upperTail ) {
 57  0
          return probability( x );
 58   
       }
 59   
 
 60  0
       if ( x < min ) return 0;
 61   
 
 62  0
       if ( x > max ) return 1.0;
 63   
 
 64  0
       return ( max - x ) / ( max - min );
 65   
    }
 66   
 
 67   
 }