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.
- class sage.probability.random_variable.DiscreteProbabilitySpace(X, P, codomain=None, check=False)[source]¶
Bases:
ProbabilitySpace_generic
,DiscreteRandomVariable
The discrete probability space
- class sage.probability.random_variable.DiscreteRandomVariable(X, f, codomain=None, check=False)[source]¶
Bases:
RandomVariable_generic
A random variable on a discrete probability space.
- covariance(other)[source]¶
The covariance of the discrete random variable X =
self
with Y =other
.Let \(S\) be the probability space of \(X\) = self, with probability function \(p\), and \(E(X)\) be the expectation of \(X\). Then the variance of \(X\) is:
\[\text{cov}(X,Y) = E((X-E(X)\cdot (Y-E(Y)) = \sum_{x \in S} p(x) (X(x) - E(X))(Y(x) - E(Y))\]
- expectation()[source]¶
The expectation of the discrete random variable, namely \(\sum_{x \in S} p(x) X[x]\), where \(X\) =
self
and \(S\) is the probability space of \(X\).
- standard_deviation()[source]¶
The standard deviation of the discrete random variable.
Let \(S\) be the probability space of \(X\) = self, with probability function \(p\), and \(E(X)\) be the expectation of \(X\). Then the standard deviation of \(X\) is defined to be
\[\sigma(X) = \sqrt{ \sum_{x \in S} p(x) (X(x) - E(x))^2}\]
- translation_correlation(other, map)[source]¶
The correlation of the probability space X =
self
with image of Y =other
under map.
- translation_covariance(other, map)[source]¶
The covariance of the probability space X =
self
with image of Y =other
under the given map of the probability space.Let \(S\) be the probability space of \(X\) = self, with probability function \(p\), and \(E(X)\) be the expectation of \(X\). Then the variance of \(X\) is:
\[\text{cov}(X,Y) = E((X-E(X)\cdot (Y-E(Y)) = \sum_{x \in S} p(x) (X(x) - E(X))(Y(x) - E(Y))\]
- translation_expectation(map)[source]¶
The expectation of the discrete random variable, namely \(\sum_{x \in S} p(x) X[e(x)]\), where \(X\) = self, \(S\) is the probability space of \(X\), and \(e\) = map.
- translation_standard_deviation(map)[source]¶
The standard deviation of the translated discrete random variable \(X \circ e\), where \(X\) =
self
and \(e\) = map.Let \(S\) be the probability space of \(X\) =
self
, with probability function \(p\), and \(E(X)\) be the expectation of \(X\). Then the standard deviation of \(X\) is defined to be\[\sigma(X) = \sqrt{ \sum_{x \in S} p(x) (X(x) - E(x))^2}\]
- translation_variance(map)[source]¶
The variance of the discrete random variable \(X \circ e\), where \(X\) = self, and \(e\) = map.
Let \(S\) be the probability space of \(X\) = self, with probability function \(p\), and \(E(X)\) be the expectation of \(X\). Then the variance of \(X\) is:
\[\mathrm{var}(X) = E((X-E(x))^2) = \sum_{x \in S} p(x) (X(x) - E(x))^2\]
- class sage.probability.random_variable.ProbabilitySpace_generic(domain, RR)[source]¶
Bases:
RandomVariable_generic
A probability space.