Class MathMAE

java.lang.Object
  |
  +--MathMAE

public class MathMAE
extends java.lang.Object

This class contains math functions used for computing statistics in MAExplorer. Some of these methods were derived from WebGel, GELLAB-II, and Numerical Recipes in C.

This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file. This notice must be included with the code. The MAExplorer Mozilla and Legal files are available on http://maexplorer.sourceforge.net/.

Version:
$Date: 2003/02/18 18:02:34 $ $Revision: $
Author:
P. Lemkin (NCI), G. Thornwall (SAIC), NCI-Frederick, Frederick, MD
See Also:
MAExplorer Home

Field Summary
static double dKS
          RTN: K-S statistic
(package private) static double[] gammln_cof
           
static double ln10
          log(10 base e
static double ln2
          log(2) base e
static double log10e
          log(e) base 10
static double log2e
          log(e) base 2
static double mnX
          RTN: mean X
static double mnY
          RTN: mean Y
static int nXY
          RTN: if calcXYstat
static boolean okBetaCF
          RTN: if nr_betacf() was ok
static boolean okBetaI
          RTN: if nr_betai() was ok
static boolean okProbKS
          RTN: if nr_probks() was ok
static double probKS
          RTN: probability of null hypoth same distrib
static double rSq
          RTN: correlation coefficient
static double sdX
          RTN: standard deviation X
static double sdY
          RTN: standard deviation Y
 
Constructor Summary
MathMAE()
           
 
Method Summary
static double alog10(double x)
          alog10() - compute alog(x) base 10.
static double alog2(double x)
          alog2() - compute alog(x) base 2.
static float calcPearsonCorrCoef(float[] data1, float[] data2, int n, boolean usePopulationCovar)
          calcPearsonCorrCoef() - compute Pearson correlation coefficient The data is data1[0:n-1] and data2[0:n-1].
static java.lang.String calcXYstat(int n, float[] xList, float[] yList, int[] propList, java.lang.String xLbl, java.lang.String yLbl)
          calcXYstat() - compute correlation statistics string for display rSq=.., n=.., X(mn+-sd)=(..+-..), Y(mn+-sd)=(..+-..) If propList[] is not null, then test if filtered using fc.IS_FILTERED value.
static float cityBlockDist(float[] data1, float[] data2, int n, boolean rtnAbsSumFlag)
          cityBlockDist() - compute city-block distance of 2 vectors.
static float euclidDist(float[] data1, float[] data2, int n, boolean rtnDistSqFlag)
          euclidDist() - compute Euclidean distance or (sum dist**2) The data is data1[0:n-1] and data2[0:n-1].
static double log10(double x)
          log10() - compute log(x) base 10.
static double log2(double x)
          log2() - compute log(x) base 2.
static double log2Zero(double x)
          log2Zero() - compute log2((x==0.0 ? 0.0 : x) - avoid log2(0.0)! This defaults log2(0.0) to log2(1.0).
static double logZero(double x)
          logZero() - compute log10((x==0.0 ? 0.0 : x) - avoid log(0.0)! This defaults log10(0.0) to log(1.0).
static double nr_betacf(double a, double b, double x)
          nr_betacf() - evaluation fct for the incomplete Beta function 'x(a,b).
static double nr_betai(double a, double b, double x)
          nr_betai() - return the incomplete Beta function 'x(a,b).
static double nr_gammln(double xx)
          nr_gammln() - Return ln(gamma()) of x by polynomial evaluation.
static boolean nr_kstwo(double[] data1, int n1, double[] data2, int n2)
          nr_kstwo() - Kolmogorov-Smirnov statistic d and the probability of the null hypothesis of 2 bins of data.
static double nr_probks(double alam)
          nr_probks() - Calc Kolmogorov-Smirnov probability qKS.
static boolean nr_sort(int n, double[] data)
          nr_sort() - quick-sort of bin of data[0:n-1] in assend.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

gammln_cof

static final double[] gammln_cof

ln10

public static final double ln10
log(10 base e

log10e

public static final double log10e
log(e) base 10

ln2

public static final double ln2
log(2) base e

log2e

public static final double log2e
log(e) base 2

okBetaCF

public static boolean okBetaCF
RTN: if nr_betacf() was ok

okBetaI

public static boolean okBetaI
RTN: if nr_betai() was ok

okProbKS

public static boolean okProbKS
RTN: if nr_probks() was ok

dKS

public static double dKS
RTN: K-S statistic

probKS

public static double probKS
RTN: probability of null hypoth same distrib

nXY

public static int nXY
RTN: if calcXYstat

rSq

public static double rSq
RTN: correlation coefficient

mnX

public static double mnX
RTN: mean X

mnY

public static double mnY
RTN: mean Y

sdX

public static double sdX
RTN: standard deviation X

sdY

public static double sdY
RTN: standard deviation Y
Constructor Detail

MathMAE

public MathMAE()
Method Detail

nr_gammln

public static double nr_gammln(double xx)
nr_gammln() - Return ln(gamma()) of x by polynomial evaluation. This method was derived from GELLAB-II which was derived from Numerical Recipes in C, Pg 168, Section 6 N.R.C.
Parameters:
xx - arg
Returns:
value

nr_betacf

public static double nr_betacf(double a,
                               double b,
                               double x)
nr_betacf() - evaluation fct for the incomplete Beta function 'x(a,b). This method was derived from GELLAB-II which was derived from Numerical Recipes in C, Pg 180, Section 6.3 N.R.C. Set the RTN: okBetaCF flag to false if there is a problem
Parameters:
a - arg
b - arg
x - arg
Returns:
value

nr_betai

public static double nr_betai(double a,
                              double b,
                              double x)
nr_betai() - return the incomplete Beta function 'x(a,b). This method was derived from GELLAB-II which was derived from Numerical Recipes in C, Pg 179, Section 6.3 N.R.C.
Parameters:
a - - a parameter of 'x(a,b)
b - - b parameter of 'x(a,b)
x - - x parameter of 'x(a,b)
Returns:
value if succeed else 0.0 if it fails and set the RTN: okBetaI flag to false.
See Also:
nr_betacf(double, double, double), nr_gammln(double)

nr_sort

public static boolean nr_sort(int n,
                              double[] data)
nr_sort() - quick-sort of bin of data[0:n-1] in assend. numerical order. Uses the partitioning-exchange sorting method. This method was derived from GELLAB-II which was derived from Numerical Recipes in C.
Parameters:
n - is the amount of data.
data - is the set of data [0:n-1].
Returns:
false if blow the stack or other problems.

nr_kstwo

public static boolean nr_kstwo(double[] data1,
                               int n1,
                               double[] data2,
                               int n2)
nr_kstwo() - Kolmogorov-Smirnov statistic d and the probability of the null hypothesis of 2 bins of data. This method was derived from GELLAB-II which was derived from Numerical Recipes in C, Pg 625, Section 14.3 N.R.C. 2nd Edition.
Parameters:
data1 - [0:n1-1] data1
n2 - # of items in data 1
data1 - [0:n2-1] data2
n2 - # of items in data 2
Returns:
false if any errors in the data or calcs. Data is returned in the global class variables: returns data in global class variables:
    RTN: dKS     -  K-S statistic, and
    RTN: probKS  - probl of null hypoth same distribution
See Also:
nr_probks(double), nr_sort(int, double[])

nr_probks

public static double nr_probks(double alam)
nr_probks() - Calc Kolmogorov-Smirnov probability qKS. This method was derived from GELLAB-II which was derived from Numerical Recipes in C, Pg 626, Section 14.3 N.R.C. 2nd Edition.
Parameters:
alam - the value computed in kstwo().
Returns:
the probability. Set okProbKS to false if there is a problem.

calcXYstat

public static java.lang.String calcXYstat(int n,
                                          float[] xList,
                                          float[] yList,
                                          int[] propList,
                                          java.lang.String xLbl,
                                          java.lang.String yLbl)
calcXYstat() - compute correlation statistics string for display rSq=.., n=.., X(mn+-sd)=(..+-..), Y(mn+-sd)=(..+-..) If propList[] is not null, then test if filtered using fc.IS_FILTERED value. This method was derived from GELLAB-II which was derived from Snedecore and Chochran Statistical Methods.
Parameters:
n - size of lists
xList - is X class data
yList - is Y class data
propList - is properties data
xLbl - is label for the X data
yLbl - is label for the Y data
Returns:
statistics string if succeed, else return null if problem.
See Also:
Util.cvd2s(double, int), Util.cvf2s(float, int)

euclidDist

public static float euclidDist(float[] data1,
                               float[] data2,
                               int n,
                               boolean rtnDistSqFlag)
euclidDist() - compute Euclidean distance or (sum dist**2) The data is data1[0:n-1] and data2[0:n-1].
Parameters:
data1 - is vector [0:n-1] of object 1
data2 - is vector [0:n-1] of object 2
n - is size of vector
rtnDistSqFlag - return(sum dist**2) else Euclidean distance.
Returns:
euclidean distance or distSq, else -1.0 if an error

cityBlockDist

public static float cityBlockDist(float[] data1,
                                  float[] data2,
                                  int n,
                                  boolean rtnAbsSumFlag)
cityBlockDist() - compute city-block distance of 2 vectors. The data vectors are data1[0:n-1] and data2[0:n-1].
Parameters:
data1 - is vector [0:n-1] of object 1
data2 - is vector [0:n-1] of object 2
n - is size of vector
rtnAbsSumFlag - return (sum absDiffs) else mean city block distance.
Returns:
city-block distance. Return -1.0 if there is an error

calcPearsonCorrCoef

public static float calcPearsonCorrCoef(float[] data1,
                                        float[] data2,
                                        int n,
                                        boolean usePopulationCovar)
calcPearsonCorrCoef() - compute Pearson correlation coefficient The data is data1[0:n-1] and data2[0:n-1]. This method was derived fromWeinstein) U. Scherf, Nat.Genetics (2000) 24:236-244, pg 243, and the version for large samples in Snedecore & Cochran 1st Edition page 175.
Parameters:
data1 - is vector [0:n-1] of object 1
data2 - is vector [0:n-1] of object 2
n - is size of vector
usePopulationCovar - flag to compute population covariance (Weinstein) U. Scherf, Nat.Genetics (2000) 24:236-244, pg 243. else version for large samples in Snedecore & Cochran 1st Edition page 175.
Returns:
calcPearsonCorrCoef else 1000.0 if there is an error

log2Zero

public static double log2Zero(double x)
log2Zero() - compute log2((x==0.0 ? 0.0 : x) - avoid log2(0.0)! This defaults log2(0.0) to log2(1.0).
Parameters:
x - argument for log2
Returns:
log2((x==0.0 ? 0.0 : x) - avoid log2(0.0)!
See Also:
log2(double)

log2

public static double log2(double x)
log2() - compute log(x) base 2. Since log2(x)= log2(e)*ln(x).
Parameters:
x - argument for log2
Returns:
log(x) base 2

alog2

public static double alog2(double x)
alog2() - compute alog(x) base 2. Since ln(x)= log2(x)/log2(e) = log2(x) * ln2.
Parameters:
x - argument for alog
Returns:
alog(x) base 2

logZero

public static double logZero(double x)
logZero() - compute log10((x==0.0 ? 0.0 : x) - avoid log(0.0)! This defaults log10(0.0) to log(1.0).
Parameters:
x - argument for log
Returns:
log10((x==0.0 ? 0.0 : x) - avoid log(0.0)!
See Also:
log10(double)

log10

public static double log10(double x)
log10() - compute log(x) base 10. Since log10(x)= log10e * ln(x).
Parameters:
x - argument for log
Returns:
log(x) base 10

alog10

public static double alog10(double x)
alog10() - compute alog(x) base 10. Since ln(x)= log10(x)/log10(e) = log10(x) * ln10.
Parameters:
x - argument for alog
Returns:
alog(x) base 10