Moments

it.grypho.scala.leonardo.probability.Moments
object Moments

The linearity rule table behind expect and variance.

This is the part that belongs in a computer algebra system rather than in a statistics library: E[aX + b] = a·E[X] + b is a rewrite, applied to the expression's structure before any number is computed, so it works while a and b are still free variables.

Structured exactly like scalar.Derive: a rule table, most specific first, with a give-up fallback. The give-up is None, which the calling node turns into "stay symbolic" — the termination guard every _Functional in this codebase shares.

What is deliberately not here. E[XY] = E[X]·E[Y] requires the factors to be independent, and nothing in the language expresses independence between two random variables. Asserting it would produce confidently wrong answers for correlated ones, so a product of two distinct random variables stays symbolic. A product where only one factor is random is fine, and is the a·X rule below.

Attributes

See also
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Moments.type

Members list

Value members

Concrete methods

def expectation(e: _Expression, x: Option[_Variable], env: Environment): Option[Either[_Expression, _Value]]

E[e], where x names the random variable (or None for a bare distribution).

E[e], where x names the random variable (or None for a bare distribution).

Value parameters

e

the expression to average

env

the evaluation environment

x

the random variable, or None for the one-argument form

Attributes

Returns

the reduced result, or None to leave the caller symbolic

def variance(e: _Expression, x: Option[_Variable], env: Environment): Option[Either[_Expression, _Value]]

Var(e), where x names the random variable (or None for a bare distribution).

Var(e), where x names the random variable (or None for a bare distribution).

Value parameters

e

the expression whose variance is wanted

env

the evaluation environment

x

the random variable, or None for the one-argument form

Attributes

Returns

the reduced result, or None to leave the caller symbolic