Package gmisclib :: Module stats
[frames] | no frames]

Module stats

source code

Some of these functions, specifically f_value(), fprob(), betai(), and betacf(), are taken from stats.py "A collection of basic statistical functions for python." by Gary Strangman. They are copyright 1999-2007 Gary Strangman; All Rights Reserved and released under the MIT license.

The rest is copyright Greg Kochanski 2009.

Functions
float
f_value(ER, EF, dfR, dfF)
Returns an F-statistic given the following:
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
 
betai(a, b, x)
Returns the incomplete beta function:
source code
 
betacf(a, b, x)
This function evaluates the continued fraction form of the incomplete Beta function, betai.
source code
 
gammaln(x)
Returns the gamma function of xx.
source code
 
test_fprob(dfnum, dfden) source code
 
t_value(ndof, p2sided=0.99) source code
float
ltqnorm(p)
Lower tail quantile for standard normal distribution function.
source code
Variables
  t_Table = [(1, 0.5, 1.0), (1, 0.95, 12.71), (1, 0.98, 31.82), ...
  __package__ = 'gmisclib'

Imports: math


Function Details

f_value(ER, EF, dfR, dfF)

source code 

Returns an F-statistic given the following:

Parameters:
  • ER - error associated with the null hypothesis (the Restricted model)
  • EF - error associated with the alternate hypothesis (the Full model)
  • dfR - degrees of freedom the Restricted model (null hypothesis)
  • dfF - degrees of freedom associated with the Full model
Returns: float
f-statistic (not the probability)

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: lfprob(dfnum, dfden, F) where usually dfnum=dfbn, dfden=dfwn

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>=0,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 Recipes in C.)

Usage: betai(a,b,x)

betacf(a, b, x)

source code 

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

Usage: betacf(a,b,x)

gammaln(x)

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. via code Copyright (c) 1999-2000 Gary Strangman and released under the LGPL.)

ltqnorm(p)

source code 

Lower tail quantile for standard normal distribution function.

This function returns an approximation of the inverse cumulative standard normal distribution function. I.e., given P, it returns an approximation to the X satisfying P = Pr{Z <= X} where Z is a random variable from the standard normal distribution.

The algorithm uses a minimax approximation by rational functions and the result has a relative error whose absolute value is less than 1.15e-9.

Parameters:
  • p (float (0,1))
Returns: float
Raises:
  • ValueError - if the argument is out of range.

Author: Peter John Acklam

Notes:
  • Time-stamp: 2000-07-19 18:26:14
  • Downloaded from http://home.online.no/~pjacklam/notes/invnorm/impl/field/ltqnorm.txt GPK 4/22/2011. Documentation at http://home.online.no/~pjacklam/notes/invnorm/index.html, which is part of this package at .../references/stats_invnorm_pjacklam_2011.html.
  • Modified from the author's original perl code (original comments follow below) by dfield@yahoo-inc.com. May 3, 2004.
Contacts:
pjacklam@online.no, Greg Kochanski <gpk@kochanski.org>

See Also: http://home.online.no/~pjacklam


Variables Details

t_Table

Value:
[(1, 0.5, 1.0),
 (1, 0.95, 12.71),
 (1, 0.98, 31.82),
 (1, 0.99, 63.66),
 (1, 0.995, 127.3),
 (1, 0.998, 318.3),
 (1, 0.999, 636.6),
 (2, 0.5, 0.816),
...