Moments
index
/Users/amos/Documents/Database/Mental/Programming/python/lib/avatar/Personal2/www.amos/Python/lib/mathlib/Statistics/Moments.py

moment-based statistics

 
Classes
       
Statistics.Statistics(__builtin__.dict)
Moments

 
class Moments(Statistics.Statistics)
    Collect statistics based on the moments (sums of powers) of the data: most notably mean and variance.
 
The statistics are returned in self['moments']: a list of length floor(cOrder)+1. if M = self['moments'], and X = getData(), then
M[0] = n, the number of data points
M[1] = E(X) = m, the mean
M[2] = E((X-m)^2) = s^2: the variance
M[3] = E((X-m)^3) / s^3 = E(Z^3) for Z = (X-m)/s: the skewness
M[4] = E((X-m)^4) / s^4 = E(Z^4): the kurtosis + 3
M[i] = E((X-m)^i) / s^i = E(Z^i), for i = 5, ..., floor(cOrder)
 
The cOrder parameter is passed to __init__, and it can be any real or floating point number. It defaults to 2.
 
There are two version of variance. One has a denominator of n in its definition, and is used when the data constitutes a finite population, or when the data is a sample from an infinite population whose mean is known. This variance is available as self['moments'][2]. The second version has a denominator of n-1 in its definition, and is used when the data is a sample from a population whose mean is estimated from the same data. This variance, more widely used in practice, is available as self['variance'], and its square root as self['std_dev'], an unbiased estimate of the population standard deviation.
 
There are two versions of the kurtosis. The first is calculated from the moments, and represents the order-4 moment: E(Z^4). These moments are (estimates of) the coefficients in the series expansion of the underlying distribution's characteristic function. There is another set of series expansion coefficients, those of the log of the characteristic functions, called the cumulants. These are the mean, standard deviation, skewness, kurtosis proper, .... The skewness is equal to the moment of order 3, and the kurtosis is the order-4 moment minus 3.
 
[I may also want to store the raw sums of squares, and calculate moments and cumulants from them. That way I can combine two separate Moments instances that I want to treat as if they were samples from the same population.]
 
 
Method resolution order:
Moments
Statistics.Statistics
__builtin__.dict
__builtin__.object

Methods defined here:
Calculate(self)
Offset(self, xOffset=None)
Standardize(self, xOffset=None, xScale=None)
__init__(self, lxData=None, cOrder=2)

Methods inherited from Statistics.Statistics:
ChSepValue(self, lsFields=None, chSep='\t')
HtmlTableRow(self, lsFields=None)
NvpTable(self, lsFields=None, isJust=False)
__repr__(self)
Recreate the constructor call.
clearData(self)
clone(self)
Return a copy of yourself except with no data.
getData(self)
getDescription(self, lsFields=None)
getPairs(self, lsFields=None)
setData(self, l)

Data descriptors inherited from Statistics.Statistics:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from __builtin__.dict:
__cmp__(...)
x.__cmp__(y) <==> cmp(x,y)
__contains__(...)
D.__contains__(k) -> True if D has a key k, else False
__delitem__(...)
x.__delitem__(y) <==> del x[y]
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__ne__(...)
x.__ne__(y) <==> x!=y
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
clear(...)
D.clear() -> None.  Remove all items from D.
copy(...)
D.copy() -> a shallow copy of D
get(...)
D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.
has_key(...)
D.has_key(k) -> True if D has a key k, else False
items(...)
D.items() -> list of D's (key, value) pairs, as 2-tuples
iteritems(...)
D.iteritems() -> an iterator over the (key, value) items of D
iterkeys(...)
D.iterkeys() -> an iterator over the keys of D
itervalues(...)
D.itervalues() -> an iterator over the values of D
keys(...)
D.keys() -> list of D's keys
pop(...)
D.pop(k[,d]) -> v, remove specified key and return the corresponding value
If key is not found, d is returned if given, otherwise KeyError is raised
popitem(...)
D.popitem() -> (k, v), remove and return some (key, value) pair as a
2-tuple; but raise KeyError if D is empty
setdefault(...)
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D
update(...)
D.update(E, **F) -> None.  Update D from E and F: for k in E: D[k] = E[k]
(if E has keys else: for (k, v) in E: D[k] = v) then: for k in F: D[k] = F[k]
values(...)
D.values() -> list of D's values

Data and other attributes inherited from __builtin__.dict:
__new__ = <built-in method __new__ of type object at 0x4edec0>
T.__new__(S, ...) -> a new object with type S, a subtype of T
fromkeys = <built-in method fromkeys of type object at 0x849520>
dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.
v defaults to None.

 
Functions
       
add(...)
add(a, b) -- Same as a + b.
mul(...)
mul(a, b) -- Same as a * b.
sqrt(...)
sqrt(x)
 
Return the square root of x.