fglib2.distributions

Module Contents

Classes

Multinomial

A multinomial distribution over discrete random variables.

class fglib2.distributions.Multinomial(variables: Iterable[random_events.variables.Discrete], probabilities: numpy.ndarray | None = None)[source]

Bases: probabilistic_model.probabilistic_model.ProbabilisticModel

A multinomial distribution over discrete random variables.

variables: Tuple[random_events.variables.Discrete][source]

The variables in the distribution.

probabilities: numpy.ndarray[source]

The probability mass function. The dimensions correspond to the variables in the same order. The first dimension indexes over the first variable and so on. If no probabilities are provided in the constructor, the probabilities are initialized with ones.

marginal(variables: Iterable[random_events.variables.Discrete]) Multinomial[source]
_mode() Tuple[List[random_events.events.EncodedEvent], float][source]
__copy__() Multinomial[source]
Returns:

a shallow copy of the distribution.

__mul__(other: Multinomial) Multinomial[source]

Multiply two Multinomial distributions and return the result.

Parameters:

other – The other distribution to multiply.

Returns:

The sum of the two distributions.

__eq__(other: Multinomial) bool[source]

Compare self with other and return the boolean result.

Two discrete random variables are equal only if the probability mass functions are equal and the order of dimensions are equal.

__str__()[source]
to_tabulate() str[source]
Returns:

a pretty table of the distribution.

_probability(event: random_events.events.EncodedEvent) float[source]
_likelihood(event: List[int]) float[source]
_conditional(event: random_events.events.EncodedEvent) Tuple[typing_extensions.Self | None, float][source]
normalize() Multinomial[source]

Normalize the distribution. :return: The normalized distribution