it.grypho.scala.leonardo.probability
Members list
Type members
Classlikes
The distribution families this package knows.
The distribution families this package knows.
An enum rather than one case class per family: every family shares the same shape — a short parameter vector plus four kernels — so a single carrier keeps Session display, :save serialization and the parser to one case each instead of five.
Attributes
- Companion
- object
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
The linearity rule table behind expect and variance.
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
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Moments.type
What a _DistributionQuery asks of a distribution.
What a _DistributionQuery asks of a distribution.
Attributes
- Companion
- object
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Companion for _Distribution: the validating factory.
Companion for _Distribution: the validating factory.
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
_Distribution.type
A probability distribution: a concrete core._Value, bindable in an Environment and round-trippable through :save.
A probability distribution: a concrete core._Value, bindable in an Environment and round-trippable through :save.
Construction routes through _Distribution.of, which validates the parameters, so every instance that exists is a well-formed distribution.
Value parameters
- kind
-
the family
- params
-
the family's parameters, in the order the grammar takes them
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Valuetrait _Expressionclass Objecttrait Matchableclass AnyShow all
Builds a distribution from parameter expressions: normal(mu, sigma) and friends.
Builds a distribution from parameter expressions: normal(mu, sigma) and friends.
The node/value split _Matrix has with _MatrixValue: this is the symbolic form, whose eval folds to a _Distribution once every parameter reduces to a number. It keeps normal(m, s) meaningful while m and s are still free variables.
Value parameters
- args
-
the parameter expressions, in the family's declared order
- kind
-
the family
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
A numeric question about a distribution: pdf, cdf, prob or quantile.
A numeric question about a distribution: pdf, cdf, prob or quantile.
One node for all four rather than four nodes, for the same reason DistKind is one enum: they differ only in which kernel they call.
Why prob(d, lo, hi) and not P(X < 2). The grammar has no comparison operators — only = and ==, which build equations — so a predicate like X < 2 cannot be expressed. Adding < and > would be a change to the expression language, not to this domain. An interval is the honest shape available today.
Value parameters
- args
-
the query's own arguments (one for
pdf/cdf/quantile, two forprob) - dist
-
the distribution expression
- query
-
the question
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
The expectation expect(e, X), or expect(d) for a distribution's own mean.
The expectation expect(e, X), or expect(d) for a distribution's own mean.
Why not E[·]. Square brackets are the matrix literal, so E[X] would parse as E times a one-element matrix. expect is unambiguous and needs no grammar change.
The one-argument form is the mean of a distribution; the two-argument form is E[e] where x names the random variable inside e, and is where the linearity rules live.
Value parameters
- e
-
the expression whose expectation is wanted, or the distribution itself
- x
-
the random variable, or
Nonefor the one-argument form
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all
The variance variance(e, X), or variance(d) for a distribution's own variance.
The variance variance(e, X), or variance(d) for a distribution's own variance.
Value parameters
- e
-
the expression whose variance is wanted, or the distribution itself
- x
-
the random variable, or
Nonefor the one-argument form
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass AnyShow all