|
|||||||||||||||||||
| 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 | |||||||||||||||
| UniformDensityComputer.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
package baseCode.math.distribution;
|
|
| 2 |
|
|
| 3 |
/**
|
|
| 4 |
* <hr>
|
|
| 5 |
* <p>
|
|
| 6 |
* Copyright (c) 2004 Columbia University
|
|
| 7 |
*
|
|
| 8 |
* @author pavlidis
|
|
| 9 |
* @version $Id: UniformDensityComputer.java,v 1.1 2004/12/31 01:14:48 pavlidis Exp $
|
|
| 10 |
*/
|
|
| 11 |
public class UniformDensityComputer implements DensityGenerator { |
|
| 12 |
|
|
| 13 |
double min = 0;
|
|
| 14 |
double max = 1;
|
|
| 15 |
|
|
| 16 |
/**
|
|
| 17 |
* Create a UniformDensityComputer where the density is defined over the unit inteval [0,1].
|
|
| 18 |
*/
|
|
| 19 | 0 |
public UniformDensityComputer() {
|
| 20 | 0 |
this( 0, 1 );
|
| 21 |
} |
|
| 22 |
|
|
| 23 |
/**
|
|
| 24 |
* Create a UniformDensityComputer where the density is defined over the interval given
|
|
| 25 |
*
|
|
| 26 |
* @param min
|
|
| 27 |
* @param max
|
|
| 28 |
*/
|
|
| 29 | 0 |
public UniformDensityComputer( double min, double max ) { |
| 30 | 0 |
if ( max <= min ) {
|
| 31 | 0 |
throw new IllegalArgumentException( "Max must be higher than min" ); |
| 32 |
} |
|
| 33 | 0 |
this.min = min;
|
| 34 | 0 |
this.max = max;
|
| 35 |
} |
|
| 36 |
|
|
| 37 |
/*
|
|
| 38 |
* (non-Javadoc)
|
|
| 39 |
*
|
|
| 40 |
* @see baseCode.math.DensityGenerator#density(double)
|
|
| 41 |
*/
|
|
| 42 | 0 |
public double density( double x ) { |
| 43 |
|
|
| 44 | 0 |
if ( x > max || x < min ) return 0; |
| 45 |
|
|
| 46 | 0 |
return 1 / ( max - min );
|
| 47 |
} |
|
| 48 |
|
|
| 49 |
} |
|
||||||||||