/
__init__.py
69 lines (59 loc) · 3.2 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""
Diofant statistics module
Introduces a random variable type into the Diofant language.
Random variables may be declared using prebuilt functions such as
Normal, Exponential, Coin, Die, etc... or built with functions like FiniteRV.
Queries on random expressions can be made using the functions
========================= =============================
Expression Meaning
------------------------- -----------------------------
``P(condition)`` Probability
``E(expression)`` Expected value
``variance(expression)`` Variance
``density(expression)`` Probability Density Function
``sample(expression)`` Produce a realization
``where(condition)`` Where the condition is true
========================= =============================
Examples
========
>>> from diofant.stats import Die, E, Normal, P, variance
>>> X, Y = Die('X', 6), Die('Y', 6) # Define two six sided dice
>>> Z = Normal('Z', 0, 1) # Declare a Normal random variable with mean 0, std 1
>>> P(X > 3) # Probability X is greater than 3
1/2
>>> E(X + Y) # Expectation of the sum of two dice
7
>>> variance(X + Y) # Variance of the sum of two dice
35/6
>>> simplify(P(Z > 1)) # Probability of Z being greater than 1
-erf(sqrt(2)/2)/2 + 1/2
"""
from .crv_types import (Arcsin, Benini, Beta, BetaPrime, Cauchy, Chi,
ChiNoncentral, ChiSquared, ContinuousRV, Dagum, Erlang,
Exponential, FDistribution, FisherZ, Frechet, Gamma,
GammaInverse, Kumaraswamy, Laplace, Logistic,
LogNormal, Maxwell, Nakagami, Normal, Pareto,
QuadraticU, RaisedCosine, Rayleigh, StudentT,
Triangular, Uniform, UniformSum, VonMises, Weibull,
WignerSemicircle)
from .drv_types import Geometric, Poisson
from .frv_types import (Bernoulli, Binomial, Coin, Die, DiscreteUniform,
FiniteRV, Hypergeometric, Rademacher)
from .rv_interface import (E, P, cdf, cmoment, correlation, covariance,
density, dependent, given, independent, moment,
pspace, random_symbols, sample, sample_iter,
sampling_density, skewness, smoment, std, variance,
where)
__all__ = ('Arcsin', 'Benini', 'Beta', 'BetaPrime', 'Cauchy', 'Chi',
'ChiNoncentral', 'ChiSquared', 'ContinuousRV', 'Dagum', 'Erlang',
'Exponential', 'FDistribution', 'FisherZ', 'Frechet', 'Gamma',
'GammaInverse', 'Kumaraswamy', 'Laplace', 'Logistic', 'LogNormal',
'Maxwell', 'Nakagami', 'Normal', 'Pareto', 'QuadraticU',
'RaisedCosine', 'Rayleigh', 'StudentT', 'Triangular', 'Uniform',
'UniformSum', 'VonMises', 'Weibull', 'WignerSemicircle',
'Geometric', 'Poisson', 'Bernoulli', 'Binomial', 'Coin', 'Die',
'DiscreteUniform', 'FiniteRV', 'Hypergeometric', 'Rademacher',
'E', 'P', 'cdf', 'cmoment', 'correlation', 'covariance', 'density',
'dependent', 'given', 'independent', 'moment', 'pspace',
'random_symbols', 'sample', 'sample_iter', 'sampling_density',
'skewness', 'smoment', 'std', 'variance', 'where')