Package PyML :: Package utils :: Module salstat_stats
[hide private]
[frames] | no frames]

Module salstat_stats

source code

The complete code in this file is copyright 2002 Alan James Salmoni, and is released under version 2 or later of the GNU General Public Licence (GPL). See the enclosed file COPYING for the full text of the licence.

Significant parts of the code were taken from stats.py by Gary Strangman of Harvard University (c) Not sure what year, Gary Strangman, released under the GNU General Public License.

Classes [hide private]
  FullDescriptives
  OneSampleTests
  TwoSampleTests
  ThreeSampleTests
  FriedmanComp
This class performs multiple comparisons on a Freidmans test.
  KWComp
This class performs multiple comparisons on a Kruskal Wallis test.
Functions [hide private]
 
add(a, b) source code
 
squared(a) source code
 
cubed(a) source code
 
quaded(a) source code
 
multiply(a, b) source code
 
obsMinusExp(a, b) source code
 
diffsquared(a, b) source code
 
higher(a, b) source code
 
lower(a, b) source code
 
shellsort(inlist)
Shellsort algorithm.
source code
 
rankdata(inlist)
Ranks the data in inlist, dealing with ties appropritely.
source code
 
tiecorrect(rankvals)
Corrects for ties in Mann Whitney U and Kruskal Wallis H tests.
source code
 
sum(inlist)
Returns the sum of the items in the passed list.
source code
 
minimaldescriptives(inlist)
this function takes a clean list of data and returns the N, sum, mean and sum of squares.
source code
 
chisqprob(chisq, df)
Returns the (1-tailed) probability value associated with the provided chi-square value and df.
source code
 
inversechi(prob, df)
This function calculates the inverse of the chi square function.
source code
 
erfcc(x)
Returns the complementary error function erfc(x) with fractional error everywhere less than 1.2e-7.
source code
 
zprob(z)
Returns the area under the normal curve 'to the left of' the given z value.
source code
 
ksprob(alam)
Computes a Kolmolgorov-Smirnov t-test significance level.
source code
 
fprob(dfnum, dfden, F)
Returns the (1-tailed) significance level (p-value) of an F statistic given the degrees of freedom for the numerator (dfR-dfF) and the degrees of freedom for the denominator (dfF).
source code
 
inversef(prob, df1, df2)
This function returns the f value for a given probability and 2 given degrees of freedom.
source code
 
betacf(a, b, x)
This function evaluates the continued fraction form of the incomplete Beta function, betai.
source code
 
gammln(xx)
Returns the gamma function of xx.
source code
 
betai(a, b, x)
Returns the incomplete beta function:
source code
Function Details [hide private]

shellsort(inlist)

source code 

Shellsort algorithm. Sorts a 1D-list.

Usage: shellsort(inlist) Returns: sorted-inlist, sorting-index-vector (for original list)

rankdata(inlist)

source code 

Ranks the data in inlist, dealing with ties appropritely. Assumes a 1D inlist. Adapted from Gary Perlman's |Stat ranksort.

Usage: rankdata(inlist) Returns: a list of length equal to inlist, containing rank scores

tiecorrect(rankvals)

source code 

Corrects for ties in Mann Whitney U and Kruskal Wallis H tests. See Siegel, S. (1956) Nonparametric Statistics for the Behavioral Sciences. New York: McGraw-Hill. Code adapted from |Stat rankind.c code.

Usage: tiecorrect(rankvals) Returns: T correction factor for U or H

sum(inlist)

source code 

Returns the sum of the items in the passed list.

Usage: sum(inlist)

chisqprob(chisq, df)

source code 

Returns the (1-tailed) probability value associated with the provided chi-square value and df. Adapted from chisq.c in Gary Perlman's |Stat.

Usage: chisqprob(chisq,df)

inversechi(prob, df)

source code 

This function calculates the inverse of the chi square function. Given a p-value and a df, it should approximate the critical value needed to achieve these functions. Adapted from Gary Perlmans critchi function in C. Apologies if this breaks copyright, but no copyright notice was attached to the relevant file.

erfcc(x)

source code 

Returns the complementary error function erfc(x) with fractional error everywhere less than 1.2e-7. Adapted from Numerical Recipies.

Usage: erfcc(x)

zprob(z)

source code 

Returns the area under the normal curve 'to the left of' the given z value.
Thus, 
    for z<0, zprob(z) = 1-tail probability
    for z>0, 1.0-zprob(z) = 1-tail probability
    for any z, 2.0*(1.0-zprob(abs(z))) = 2-tail probability
Adapted from z.c in Gary Perlman's |Stat.

Usage:   zprob(z)

ksprob(alam)

source code 

Computes a Kolmolgorov-Smirnov t-test significance level. Adapted from Numerical Recipies.

Usage: ksprob(alam)

fprob(dfnum, dfden, F)

source code 

Returns the (1-tailed) significance level (p-value) of an F statistic given the degrees of freedom for the numerator (dfR-dfF) and the degrees of freedom for the denominator (dfF).

Usage: fprob(dfnum, dfden, F) where usually dfnum=dfbn, dfden=dfwn

inversef(prob, df1, df2)

source code 

This function returns the f value for a given probability and 2 given degrees of freedom. It is an approximation using the fprob function. Adapted from Gary Perlmans critf function - apologies if copyright is broken, but no copyright notice was attached

betacf(a, b, x)

source code 

This function evaluates the continued fraction form of the incomplete Beta function, betai. (Adapted from: Numerical Recipies in C.)

Usage: betacf(a,b,x)

gammln(xx)

source code 

Returns the gamma function of xx.
    Gamma(z) = Integral(0,infinity) of t^(z-1)exp(-t) dt.
(Adapted from: Numerical Recipies in C.)

Usage:   gammln(xx)

betai(a, b, x)

source code 

Returns the incomplete beta function:

    I-sub-x(a,b) = 1/B(a,b)*(Integral(0,x) of t^(a-1)(1-t)^(b-1) dt)

where a,b>0 and B(a,b) = G(a)*G(b)/(G(a+b)) where G(a) is the gamma
function of a.  The continued fraction formulation is implemented here,
using the betacf function.  (Adapted from: Numerical Recipies in C.)

Usage:   betai(a,b,x)