Goulib.stats module¶
very basic statistics functions
-
Goulib.stats.
mean_var
(data)[source]¶ mean and variance by stable algorithm :param :return: float (mean, variance) of data uses a stable algo by Knuth
-
Goulib.stats.
avg
(data)¶ Returns: mean of data
-
Goulib.stats.
variance
(data)[source]¶ Returns: variance of data, faster (?) if mean is already available
-
Goulib.stats.
var
(data)¶ Returns: variance of data, faster (?) if mean is already available
-
Goulib.stats.
confidence_interval
(data, conf=0.95)[source]¶ Returns: (low,high) bounds of 95% confidence interval of data
-
class
Goulib.stats.
Stats
(data=[], mean=None, var=None)[source]¶ Bases:
object
an object that computes mean, variance and modes of data that is appended to it as in a list (but actual values are not stored)
-
sum
¶
-
sum1
¶
-
sum2
¶
-
mean
¶
-
avg
¶
-
average
¶
-
mu
¶
-
variance
¶
-
var
¶
-
stddev
¶
-
sigma
¶
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
() → list¶ default dir() implementation
-
__eq__
¶ Return self==value.
-
__format__
()¶ default object formatter
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__str__
¶ Return str(self).
-
-
class
Goulib.stats.
Discrete
(data)[source]¶ Bases:
Goulib.stats.Stats
discrete probability density function
Parameters: data – can be: - list of equiprobable values (uniform distribution)
- dict of x:p values:probability pairs
-
__init__
(data)[source]¶ Parameters: data – can be: - list of equiprobable values (uniform distribution)
- dict of x:p values:probability pairs
-
__add__
(other)¶
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
() → list¶ default dir() implementation
-
__eq__
¶ Return self==value.
-
__format__
()¶ default object formatter
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__mul__
(other)¶
-
__ne__
¶ Return self!=value.
-
__neg__
()¶
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__pow__
(n)¶
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__repr__
()¶
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__str__
¶ Return str(self).
-
__sub__
(other)¶
-
append
(x)¶ add data x to Stats
-
average
¶
-
avg
¶
-
covariance
(other)¶
-
extend
(data)¶
-
mean
¶
-
mu
¶
-
remove
(data)¶ remove data from Stats :param data: value or iterable of values
-
sigma
¶
-
stddev
¶
-
sum
¶
-
sum1
¶
-
sum2
¶
-
var
¶
-
variance
¶
-
class
Goulib.stats.
PDF
(pdf, data=[])[source]¶ Bases:
Goulib.expr.Expr
,Goulib.stats.Stats
probability density function
-
__add__
(right)¶
-
__and__
(right)¶
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
() → list¶ default dir() implementation
-
__div__
(right)¶
-
__eq__
(other)¶
-
__float__
()¶
-
__format__
()¶ default object formatter
-
__ge__
(other)¶
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
(other)¶
-
__hash__
= None¶
-
__invert__
()¶
-
__le__
(other)¶
-
__lshift__
(dx)¶
-
__lt__
(other)¶
-
__mul__
(right)¶
-
__ne__
(other)¶
-
__neg__
()¶
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__or__
(right)¶
-
__pow__
(right)¶
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__repr__
()¶
-
__rmul__
(right)¶
-
__rshift__
(dx)¶
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__str__
()¶
-
__sub__
(right)¶
-
__truediv__
(right)¶
-
__xor__
(right)¶
-
append
(x)¶ add data x to Stats
-
applx
(f, var='x')¶ function composition f o self = self(f(x))
-
apply
(f, right=None)¶ function composition self o f = f(self(x))
-
average
¶
-
avg
¶
-
complexity
()¶ measures the complexity of Expr :return: int, sum of the precedence of used ops
-
covariance
(other)¶
-
extend
(data)¶
-
html
(**kwargs)¶
-
isNum
¶
-
isconstant
¶ Returns: True if Expr evaluates to a constant number or bool
-
latex
()¶ Returns: string LaTex formula
-
mean
¶
-
mu
¶
-
plot
(**kwargs)¶ renders on IPython Notebook (alias to make usage more straightforward)
-
png
(**kwargs)¶
-
remove
(data)¶ remove data from Stats :param data: value or iterable of values
-
render
(fmt='svg', **kwargs)¶
-
save
(filename, **kwargs)¶
-
sigma
¶
-
stddev
¶
-
sum
¶
-
sum1
¶
-
sum2
¶
-
svg
(**kwargs)¶
-
var
¶
-
variance
¶
-
-
class
Goulib.stats.
Normal
(data=[], mean=0, var=1)[source]¶ Bases:
Goulib.stats.PDF
represents a normal distributed variable the base class (list) optionally contains data
if data is specified, it it used to fit a normal law
-
sigma
¶
-
__truediv__
(a)¶
-
cov
(other)¶
-
correlation
(other)¶
-
corr
(other)¶
-
__and__
(right)¶
-
__call__
(x=None, **kwargs)¶
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
() → list¶ default dir() implementation
-
__eq__
(other)¶
-
__float__
()¶
-
__format__
()¶ default object formatter
-
__ge__
(other)¶
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
(other)¶
-
__hash__
= None¶
-
__invert__
()¶
-
__le__
(other)¶
-
__lshift__
(dx)¶
-
__lt__
(other)¶
-
__ne__
(other)¶
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__or__
(right)¶
-
__pow__
(right)¶
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__repr__
()¶
-
__rmul__
(right)¶
-
__rshift__
(dx)¶
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__xor__
(right)¶
-
append
(x)¶ add data x to Stats
-
applx
(f, var='x')¶ function composition f o self = self(f(x))
-
apply
(f, right=None)¶ function composition self o f = f(self(x))
-
average
¶
-
avg
¶
-
complexity
()¶ measures the complexity of Expr :return: int, sum of the precedence of used ops
-
extend
(data)¶
-
html
(**kwargs)¶
-
isNum
¶
-
isconstant
¶ Returns: True if Expr evaluates to a constant number or bool
-
mean
¶
-
mu
¶
-
plot
(**kwargs)¶ renders on IPython Notebook (alias to make usage more straightforward)
-
png
(**kwargs)¶
-
remove
(data)¶ remove data from Stats :param data: value or iterable of values
-
render
(fmt='svg', **kwargs)¶
-
save
(filename, **kwargs)¶
-
stddev
¶
-
sum
¶
-
sum1
¶
-
sum2
¶
-
svg
(**kwargs)¶
-
var
¶
-
variance
¶
-
-
Goulib.stats.
linear_regression
(x, y, conf=None)[source]¶ Parameters: - x,y – iterable data
- conf – float confidence level [0..1]. If None, confidence intervals are not returned
Returns: b0,b1,b2, (b0
Return the linear regression parameters and their <prob> confidence intervals.
ex: >>> linear_regression([.1,.2,.3],[10,11,11.5],0.95)