Class MathCM

java.lang.Object
  extended by MathCM

public class MathCM
extends java.lang.Object

Class MathCM contains utility Math functions not found in the Java Math package. Results that are compute are left in the CALC variables.

 List of Methods
=================== nr_gammln() - Return ln(gamma()) of x by polynomial evaluation. nr_betai() - return the incomplete Beta function 'x(a,b) nr_betacf() - evaluation fct for the incomplete Beta function 'x(a,b). calcFprobFromVariances() - calculate 2-tailed f probility that variables are same. calcTandPvalues() - calculate f, t, p, dF from (n1,m1,s1) and (n2,m2,s2).
This code is available at the HTMLtools project on SourceForge at http://htmltools.sourceforge.org/ under the "Common Public License Version 1.0" http://www.opensource.org/licenses/cpl1.0.php.

It was derived and refactored from the open source MAExplorer (http://maexplorer.sourceforge.org/), and Open2Dprot (http://Open2Dprot.sourceforge.net/) Table modules.

$Date: 2009/12/09 11:45:56 $ $Revision: 1.41 $
Copyright 2008, 2009 by Peter Lemkin E-Mail: lemkin@users.sourceforge.net http://lemkingroup.com/


Field Summary
 double dF
          CALC: degrees of freedom of t-test or F-test (2 conditions) set by calcTandPvalues()
 double f
          CALC: calculated f statistic set by calcTandPvalues()
 double fStat
          CALC: f-statistic 2 conditions
static double[] gammln_cof
           
static boolean okBetaCF
          RTN: if nr_betacf() was ok
static boolean okBetaI
          RTN: if nr_betai() was ok
 double pF
          CALC: f-test p-value w/NULL hypoth set by calcTandPvalues()
 double pT
          CALC: t-test p-value w/NULL hypoth set by calcTandPvalues()
 double t
          CALC: t or t' statistic set by calcTandPvalues()
private  char useTest
          CALC: 'B' or 'T' - t-test to use set by calcTandPvalues()
 
Constructor Summary
MathCM()
          MathCM() - Constructor
 
Method Summary
(package private)  boolean calcFprobFromVariances(int n1, int n2, double var1, double var2)
          calcFprobFromVariances() - calculate 2-tailed f probility that variables are same.
(package private)  boolean calcTandPvalues(int n1, int n2, double m1, double m2, double s1, double s2)
          calcTandPvalues() - calculate f, t, p, dF from (n1,m1,s1) and (n2,m2,s2).
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gammln_cof

public static final double[] gammln_cof

okBetaCF

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


okBetaI

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


pT

public double pT
CALC: t-test p-value w/NULL hypoth set by calcTandPvalues()


pF

public double pF
CALC: f-test p-value w/NULL hypoth set by calcTandPvalues()


dF

public double dF
CALC: degrees of freedom of t-test or F-test (2 conditions) set by calcTandPvalues()


t

public double t
CALC: t or t' statistic set by calcTandPvalues()


f

public double f
CALC: calculated f statistic set by calcTandPvalues()


fStat

public double fStat
CALC: f-statistic 2 conditions


useTest

private char useTest
CALC: 'B' or 'T' - t-test to use set by calcTandPvalues()

Constructor Detail

MathCM

public MathCM()
MathCM() - Constructor

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_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_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

calcFprobFromVariances

boolean calcFprobFromVariances(int n1,
                               int n2,
                               double var1,
                               double var2)
calcFprobFromVariances() - calculate 2-tailed f probility that variables are same. It computes:
    fStat - the f-statistic
    pF    - CALC: probab. vars. same
This method was derived from GELLAB-II which was derived from Numerical Recipes in C and Snedecore and Chochran Statistical Methods.

Parameters:
n1 - # samples class 1
n2 - # samples class 2
var1 - variance of class 1
var2 - variance of class 2
Returns:
true and set variables if succeed, else false if any problems.
See Also:
nr_betai(double, double, double)

calcTandPvalues

boolean calcTandPvalues(int n1,
                        int n2,
                        double m1,
                        double m2,
                        double s1,
                        double s2)
calcTandPvalues() - calculate f, t, p, dF from (n1,m1,s1) and (n2,m2,s2). Use Behrens-Fisher/Satterthwaite estimate for t and dF if f-stat is < 0.05 p-value that variances are different. Otherwise use the standard student t-statistic with DF= (n1+n2-2). If you want to force the test the set useTest to 'B' or 'T', else it will pick the test to use (ie. TB or TP). It uses the algorithm described Numerical Recipes in C (1st Ed) for estimating p-value given the t-statistic using the incomplete beta function betai(). It computes:
    f - calculated f statistic
    t - t or t' statistic
    pT - t-test p-value w/NULL hypoth
    pF - f-test p-value w/NULL hypoth
    dF - degrees of freedom
 
This method was derived from GELLAB-II which was derived from Numerical Recipes in C and Snedecore and Chochran Statistical Methods.

Parameters:
n1 - # samples in class 1
n2 - # samples in class 2
m1 - sample mean class 1
m2 - sample mean class 2
s1 - sample std dev class 1
s2 - sample std dev class 2
Returns:
false if any of the data is invalid (need >= 2 samples/class) or the beta fct fails.
See Also:
nr_betai(double, double, double), calcFprobFromVariances(int, int, double, double)