prodigy.distribution.fast_generating_function¶
- class FPS(expression, *variables, finite=None)[source]¶
Bases:
DistributionThis class models a probability distribution in terms of a formal power series. These formal powerseries are itself provided by prodigy a python binding to GiNaC, something similar to a computer algebra system implemented in C++.
- get_probability_mass()[source]¶
Returns the probability mass of the distribution.
- Return type:
VarExpr|BoolLitExpr|NatLitExpr|RealLitExpr|UnopExpr|BinopExpr|CategoricalExpr|SubstExpr|TickExpr|FunctionCallExpr|InferExpr|SampleExpr|str
- get_expected_value_of(expression)[source]¶
Returns the expected value of the expression expression evaluated in the distribution.
- get_symbols()[source]¶
Returns all symbols that occur in this distribution (a subset of self.get_variables() | self.get_parameters()).
- hadamard_product(other)[source]¶
Computes the Hadamard product of the distributions, i.e., the point-wise product of the probabilities.
- Parameters:
other (
Distribution)- Return type:
- old_update(expression)[source]¶
- Parameters:
expression (
VarExpr|BoolLitExpr|NatLitExpr|RealLitExpr|UnopExpr|BinopExpr|CategoricalExpr|SubstExpr|TickExpr|FunctionCallExpr|InferExpr|SampleExpr)- Return type:
- get_fresh_variable(exclude=frozenset({}))[source]¶
Returns a str that is the name of neither an existing variable nor an existing parameter of this distribution nor contained in the exclude parameter.
- update_iid(sampling_dist, count, variable)[source]¶
Updates the distribution by the the iid-sampling rules.
- marginal(*variables, method=MarginalType.INCLUDE)[source]¶
Computes the marginal distribution for the given variables (MarginalType.Include), or for all but the given variables (MarginalType.Exclude).
- Parameters:
variables (
str|VarExpr) – A list of variables for which the marginal distribution should be computed. If this list is empty or contains symbols that are not known variables of this distribution, this function will raise an exception.method (
MarginalType) – The method of marginalization.
- Return type:
- Returns:
The marginal distribution.
- approximate(threshold)[source]¶
Computes the approximation until the given threshold is reached (might not terminate).
- class ProdigyPGF(*args, **kwargs)[source]¶
Bases:
CommonDistributionsFactory- static geometric(var, p)[source]¶
A geometric distribution with success probability p, i.e., p + p*(1-p)*x + p*(1-p)^2*x^2 + ….
- static uniform(var, lower, upper)[source]¶
A uniform distribution with bounds [lower,`upper`].
- Parameters:
var (
str|VarExpr)lower (
str|VarExpr|BoolLitExpr|NatLitExpr|RealLitExpr|UnopExpr|BinopExpr|CategoricalExpr|SubstExpr|TickExpr|FunctionCallExpr|InferExpr|SampleExpr)upper (
str|VarExpr|BoolLitExpr|NatLitExpr|RealLitExpr|UnopExpr|BinopExpr|CategoricalExpr|SubstExpr|TickExpr|FunctionCallExpr|InferExpr|SampleExpr)
- Return type:
- static binomial(var, n, p)[source]¶
A binomial distribution with parameters n and p.
- Parameters:
var (
str|VarExpr)n (
str|VarExpr|BoolLitExpr|NatLitExpr|RealLitExpr|UnopExpr|BinopExpr|CategoricalExpr|SubstExpr|TickExpr|FunctionCallExpr|InferExpr|SampleExpr)p (
str|VarExpr|BoolLitExpr|NatLitExpr|RealLitExpr|UnopExpr|BinopExpr|CategoricalExpr|SubstExpr|TickExpr|FunctionCallExpr|InferExpr|SampleExpr)
- Return type:
- static undefined(*variables)[source]¶
A distribution where actually no information about the states is given.