object.common
Class HypDistanceCalculator

java.lang.Object
  extended by object.common.HypDistanceCalculator

public class HypDistanceCalculator
extends java.lang.Object

This class calculates cumulative Hypergeometric distances, used for p-value calculations.


Field Summary
static int ROUNDING_STRATEGY
          The rounding strategy for the calculations.
static int SCALE
          The number of digits after the first non-zero digit in the decimal part of a number.
 
Constructor Summary
HypDistanceCalculator()
           
 
Method Summary
protected static int approximateScale(java.math.BigDecimal divisor, java.math.BigDecimal dividend)
           
static double calculateHypDistance(int population, int population_true, int sample, int sample_true, boolean fast)
           
static java.math.BigDecimal combinations(int n, int k)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCALE

public static final int SCALE
The number of digits after the first non-zero digit in the decimal part of a number. This is used for division calculations.

See Also:
Constant Field Values

ROUNDING_STRATEGY

public static final int ROUNDING_STRATEGY
The rounding strategy for the calculations. The options are described in java.math.BigDecimal.

See Also:
Constant Field Values
Constructor Detail

HypDistanceCalculator

public HypDistanceCalculator()
Method Detail

calculateHypDistance

public static double calculateHypDistance(int population,
                                          int population_true,
                                          int sample,
                                          int sample_true,
                                          boolean fast)
Parameters:
population - the total population
population_true - the population that is true
sample - the sample size
sample_true - the items in sample that are in population_true
fast - whether the calculation should be done fast, at expense of some precision
Returns:
the hypergeometric distance for the given parameters

approximateScale

protected static int approximateScale(java.math.BigDecimal divisor,
                                      java.math.BigDecimal dividend)

combinations

public static java.math.BigDecimal combinations(int n,
                                                int k)
Returns:
n choose k