Module: sage.probability.random_variable
Random variables and probability spaces
This introduces a class of random variables, with the focus on discrete random variables (i.e. on a discrete probability space). This avoids the problem of defining a measure space and measurable functions.
Module-level Functions
| S) |
| X) |
| S) |
| X) |
Class: DiscreteProbabilitySpace
| self, X, P, [codomain=None], [check=False]) |
sage: S = [ i for i in range(16) ]
sage: P = {}
sage: for i in range(15): P[i] = 2^(-i-1)
sage: P[15] = 2^-16
sage: X = DiscreteProbabilitySpace(S,P)
sage: X.domain()
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
sage: X.set()
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
sage: X.entropy()
1.9997253418
A probability space can be defined on any list of elements.
sage: AZ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
sage: S = [ AZ[i] for i in range(26) ]
sage: P = { 'A':1/2, 'B':1/4, 'C':1/4 }
sage: X = DiscreteProbabilitySpace(S,P)
sage: X
Discrete probability space defined by {'A': 1/2, 'C': 1/4, 'B': 1/4}
sage: X.entropy()
1.5
Functions: entropy,
set
| self) |
| self) |
Special Functions: __repr__
Class: DiscreteRandomVariable
| self, X, f, [codomain=None], [check=False]) |
INPUT:
x: A probability space
f: A dictionary such that X[x] = value for x in X
is the discrete function on X
Functions: correlation,
covariance,
expectation,
function,
standard_deviation,
translation_correlation,
translation_covariance,
translation_expectation,
translation_standard_deviation,
translation_variance,
variance
| self, other) |
| self, other) |
Let
be the probability space of
= self, with probability function
,
and
be the expectation of
. Then the variance of
is:
| self) |
| self) |
| self) |
Let
be the probability space of
= self, with probability function
,
and
be the expectation of
. Then the standard deviation of
is defined to be
| self, other, map) |
| self, other, map) |
Let
be the probability space of
= self, with probability function
,
and
be the expectation of
. Then the variance of
is:
| self, map) |
| self, map) |
Let
be the probability space of
= self, with probability function
,
and
be the expectation of
. Then the standard deviation of
is defined to be
| self, map) |
Let
be the probability space of
= self, with probability function
,
and
be the expectation of
. Then the variance of
is:
| self) |
Let
be the probability space of
= self, with probability function
,
and
be the expectation of
. Then the variance of
is:
Special Functions: __call__,
__repr__
| self, x) |
Class: ProbabilitySpace_generic
| self, domain, RR) |
Functions: domain
Class: RandomVariable_generic
| self, X, RR) |
Functions: codomain,
domain,
field,
probability_space
See About this document... for information on suggesting changes.