Bernoulli

probula.Bernoulli
See theBernoulli companion object
class Bernoulli[T](val name: Name)(p: Double, success: T, failure: T) extends Dist[T], HasDensity[T]

Attributes

Companion
object
Graph
Supertypes
trait HasDensity[T]
trait Dist[T]
trait CanSample[T]
trait Named
class Object
trait Matchable
class Any
Show all

Members list

Type members

Inherited classlikes

class WithFilter(p: T => Boolean)

Not used presently.

Not used presently.

Attributes

Inherited from:
Dist
Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

def logDensity(t: T): LogScore
def sample[S >: T](using rng: RNG): IData[S]

Inherited methods

infix def ->[U](that: Dist[U]): Dist[(T, U)]

Same as zip.

Same as zip.

Attributes

Inherited from:
Dist
def _flatMap[U](f: T => Dist[U]): Dist[(T, U)]

Add a new variable to the this model by flatMapping function f.

Add a new variable to the this model by flatMapping function f.

Users should typically use the probDep function instead, as _flatMap. The resulting model has arity higher by 1 than this. The new variable is given no name.

Value parameters

f

The function to be flatMapped to derive the new variable.

Attributes

Returns

The model created by flatMapping and adding the result to the existing model tuple.

See also

probDep

Inherited from:
Dist
def _flatMap[U](l: String)(f: T => Dist[U]): Dist[(T, U)]

Add a new variable to the this model by flatMapping function f.

Add a new variable to the this model by flatMapping function f.

Users should typically use the probDep function instead, as _flatMap. The resulting model has arity higher by 1 than this.

Value parameters

f

The function to be flatMapped to derive the new variable.

l

The descriptive name of the only variable in the new model.

Attributes

Returns

The model created by flatMapping and adding the result to the existing model tuple.

See also

probDep

Inherited from:
Dist
def _map[U](f: T => U): Dist[(T, U)]

Add a new variable (dimension) to this model by mapping function f. The new variable is just added to the current model, so the arity of the model increases by one. Users should use detDep instead.

Add a new variable (dimension) to this model by mapping function f. The new variable is just added to the current model, so the arity of the model increases by one. Users should use detDep instead.

The new variable will be using the same name as this but suffixed with _map.

Attributes

See also

detDep

Inherited from:
Dist
def _map[U](l: String)(f: T => U): Dist[(T, U)]

Add a new variable (dimension) to this model by mapping function f. The new variable is just added to the current model, so the arity of the model increases by one. Users should use detDep instead.

Add a new variable (dimension) to this model by mapping function f. The new variable is just added to the current model, so the arity of the model increases by one. Users should use detDep instead.

Value parameters

name

The descriptive name of the newly added variable

Attributes

See also

detDep

Inherited from:
Dist
def _map2[U, V](that: Dist[U])(f: ((T, U)) => V): Dist[(T, U, V)]

Attributes

Inherited from:
Dist
def _map2[U, V](other: Dist[U])(f: (T, U) => V): Dist[(T, U, V)]

Attributes

Inherited from:
Dist
def condition[S >: T](value: S): Dist[T]

Reject all the values of the model that differ from value using a usual equality test ==.

Reject all the values of the model that differ from value using a usual equality test ==.

This is also called conditioning. The new filtered model will have the same name as this but suffixed with filter.

The same as filter.

Attributes

Inherited from:
Dist
def condition(p: T => Boolean): Dist[T]

Reject all the values of the model that do not satisfy p.

Reject all the values of the model that do not satisfy p.

This is also called conditioning. The new filtered model will have the same name as this but suffixed with filter.

The same as filter.

Attributes

Inherited from:
Dist
def density(t: T): Double

Attributes

Inherited from:
HasDensity
def filter[S >: T](value: S): Dist[T]

Reject all the values of the model that differ from value using a usual equality test ==.

Reject all the values of the model that differ from value using a usual equality test ==.

This is also called conditioning. The new filtered model will have the same name as this but suffixed with filter.

Attributes

Inherited from:
Dist
def filter(p: T => Boolean): Dist[T]

Reject all the values of the model that do not satisfy p.

Reject all the values of the model that do not satisfy p.

This is also called conditioning. The new filtered model will have the same name as this but suffixed with filter.

Attributes

Inherited from:
Dist
def flatMap[U](f: T => Dist[U]): Dist[U]

Create a univariate[1] model by mapping function f on this model.

Create a univariate[1] model by mapping function f on this model.

Users should typically use the probDep function instead, as flatMap "hides" all the existing variables in the model, and the resulting model is univariate, regardless how many variables this had.

[1] Technically the resulting model does not have to be univariate, even though it typically is. It will have the arity of type U.

Value parameters

f

The function to be mapped.

Attributes

Returns

The model created by mapping. All original variables are hidden (lost). The new model carries the same name as this but suffixed with flatMap.

See also

probDep

Inherited from:
Dist
def flatMap[U](l: String)(f: T => Dist[U]): Dist[U]

Create a univariate[1] model by mapping function f the this model.

Create a univariate[1] model by mapping function f the this model.

Users should typically use the probDep function instead, as flatMap "hides" all the existing variables in the model, and the resulting model is univariate, regardless how many variables this had.

[1] Technically the resulting model does not have to be univariate, even though it typically is. It will have the arity of type U.

Value parameters

f

The function to be mapped.

l

The descriptive name of the only variable in the new model.

Attributes

Returns

The model created by mapping. All original variables are hidden (lost)

See also

probDep

Inherited from:
Dist
def label(l: String): Dist[T]

Change the name of the current model/variable to an arbitrary string l.

Change the name of the current model/variable to an arbitrary string l.

Attributes

Inherited from:
Dist
def map[U](f: T => U): Dist[U]

Create a univariate[1] model by mapping a function on the this model. Users should typically use the detDep function instead, as map "hides" all the existing variables in the model, and the resulting model is univariate, regardless how many variables this had.

Create a univariate[1] model by mapping a function on the this model. Users should typically use the detDep function instead, as map "hides" all the existing variables in the model, and the resulting model is univariate, regardless how many variables this had.

The variable in the model resulting model will have the same descriptive name as the this node had, but suffixed with map.

[1] Technically the resulting model does not have to be univariate, even though it typically is. It will have the arity of type U.

Attributes

See also

detDep

Inherited from:
Dist
def map[U](l: String)(f: T => U): Dist[U]

Create a univariate[1] model by mapping a function on the this model. Users should typically use the detDep function instead, as map "hides" all the existing variables in the model, and the resulting model is univariate, regardless how many variables this had.

Create a univariate[1] model by mapping a function on the this model. Users should typically use the detDep function instead, as map "hides" all the existing variables in the model, and the resulting model is univariate, regardless how many variables this had.

[1] Technically the resulting model does not have to be univariate, even though it typically is. It will have the arity of type U.

Value parameters

name

The descriptive name of the only variable in the new model.

Attributes

See also

detDep

Inherited from:
Dist
def map2[U, V](other: Dist[U])(f: ((T, U)) => V): Dist[V]

Attributes

Inherited from:
Dist
def map2[U, V](other: Dist[U])(f: (T, U) => V): Dist[V]

Attributes

Inherited from:
Dist
def matching[A](f: PartialFunction[T, A]): Dist[T]

Reject all the values of the model that do not match the pattern in the partial function f (so more precisely for which f is not defined). In practice f is a case clause without a body as the body is not executed by matching.

Reject all the values of the model that do not match the pattern in the partial function f (so more precisely for which f is not defined). In practice f is a case clause without a body as the body is not executed by matching.

This is also called conditioning. The new filtered model will have the same name as this but suffixed with filter.

Attributes

Inherited from:
Dist
def observe(t: T): LogScore

Attributes

Inherited from:
HasDensity
def sample[U >: T](n: SampleSize)(using RNG): IData[U]

Attributes

Inherited from:
CanSample
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Dist -> Any
Inherited from:
Dist
def zip[U](that: Dist[U]): Dist[(T, U)]

Zip two variables into one bivariate variable. This should typically be used only for variables constructed with basic constructors (independent).

Zip two variables into one bivariate variable. This should typically be used only for variables constructed with basic constructors (independent).

Attributes

Inherited from:
Dist

Concrete fields

val logP: LogScore
val logQ: LogScore
val name: Name