Goulib.stats

very basic statistics functions

In [1]:
from Goulib.notebook import *
from Goulib.stats import *

Discrete distributions

In [2]:
dice=Discrete(range(1,6+1))
dice
Out[2]:
Discrete(mean=3.5, var=3.5)
In [3]:
Y=Discrete({1:0.2, -1:0.8})
Y
Out[3]:
Discrete(mean=-0.6, var=2)
In [9]:
X=Discrete({-2:0.15,-1:.2,0:.3,1:.2,2:.15})
X**2+Y
Out[9]:
Stats(mean=-0.3, var=8.640625)

Normal distribution

In [5]:
n1=Normal()
print(n1)
n1
Normal(mean=0, var=1)
Out[5]:
$\mathcal{N}(\mu=0, \sigma=1)$
In [6]:
n2=Normal([],4,4)
n2
Out[6]:
$\mathcal{N}(\mu=4, \sigma=2)$
In [7]:
n1+n2
Out[7]:
$\mathcal{N}(\mu=4, \sigma=\sqrt {5})$
In [8]:
plot.plot([n1,n2,n1+n2])
Out[8]: