_Distribution

it.grypho.scala.leonardo.probability._Distribution
See the_Distribution companion object
final case class _Distribution extends _Value

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
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait _Value
trait _Expression
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def cdf(x: Double): Option[Double]

The cumulative distribution function P(X ≤ x).

The cumulative distribution function P(X ≤ x).

Every one of these is a closed form built on the special-function kernels rather than a numeric integral of pdf: the normal is erfc, the gamma-family tails are the regularised incomplete gamma, and the binomial tail is the regularised incomplete beta. Numeric integration is available through _DefIntegral for anything added later that has no closed form, but using it here would be slower and less accurate for no reason.

Value parameters

x

the point

Attributes

Returns

P(X ≤ x) in [0, 1], or None where undefined

override def children: List[_Expression]

Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.

Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.

Attributes

Definition Classes
def display(precision: Int): String

Renders at precision decimal places, as the grammar call that rebuilds it.

Renders at precision decimal places, as the grammar call that rebuilds it.

Value parameters

precision

decimal places for the parameters

Attributes

override def eval(env: Environment): Either[_Expression, _Value]

Returns Right(this) — a distribution is already fully reduced.

Returns Right(this) — a distribution is already fully reduced.

Attributes

Definition Classes
def isDiscrete: Boolean

Whether this family is supported on the integers rather than on an interval.

Whether this family is supported on the integers rather than on an interval.

Decides which of pdf and pmf is meaningful, and makes prob sum rather than subtract cdfs at the lower endpoint — for a discrete family P(lo ≤ X ≤ hi) has to include lo itself.

Attributes

def mean: Option[Double]

The mean E[X].

The mean E[X].

Attributes

Returns

the mean, or None if it does not exist

def pdf(x: Double): Option[Double]

The density at x (continuous families) or the mass at x (discrete ones).

The density at x (continuous families) or the mass at x (discrete ones).

Value parameters

x

the point

Attributes

Returns

the density or mass, or None where the family is undefined

def probability(lo: Double, hi: Double): Option[Double]

P(lo ≤ X ≤ hi).

P(lo ≤ X ≤ hi).

For a discrete family the lower endpoint is included, which cdf(hi) − cdf(lo) would silently exclude — P(1 ≤ X ≤ 3) on a binomial must count X = 1.

Value parameters

hi

the upper bound

lo

the lower bound

Attributes

Returns

the probability, or None where undefined

override def rebuild(c: List[_Expression]): _Expression

Reconstructs the same node shape with replacement sub-expressions.

Reconstructs the same node shape with replacement sub-expressions.

Value parameters

newChildren

replacements in the same order and count as children

Attributes

Definition Classes
override def toString: String

Renders as the grammar call that rebuilds it, so a bound distribution round-trips.

Renders as the grammar call that rebuilds it, so a bound distribution round-trips.

Attributes

Definition Classes
Any
def variance: Option[Double]

The variance Var(X).

The variance Var(X).

Attributes

Returns

the variance, or None if it does not exist

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product

Inherited fields

lazy val freeVars: Set[String]

Cached set of free variable names; O(1) after the first access.

Cached set of free variable names; O(1) after the first access.

Attributes

Inherited from:
_Expression