prodigy.distribution.symengine_distribution¶
- class SymengineDist(function, *variables)[source]¶
Bases:
Distribution- Parameters:
variables (
Symbol|str)
- iter_with(monomial_iterator)[source]¶
Iterates over the expression with a custom monomial order. :type monomial_iterator:
Iterator[List[int]] :param monomial_iterator: An iterator that yields the monomial order.
- get_prob_by_diff(state)[source]¶
Get the probability of a given state by means of differentiation :type state:
State:param state: The state to get the probability of- Return type:
Basic- Returns:
The probability of the given state
- get_prob_by_series(state)[source]¶
Get the probability of a given state by means of taylor expansion :type state:
State:param state: The state to get the probability of- Return type:
Basic- Returns:
The probability of the given state
- get_expected_value_of(expression)[source]¶
Returns the expected value of the expression expression evaluated in the distribution.
- 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:
- 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.
- Parameters:
sampling_dist (
VarExpr|BoolLitExpr|NatLitExpr|RealLitExpr|UnopExpr|BinopExpr|CategoricalExpr|SubstExpr|TickExpr|FunctionCallExpr|InferExpr|SampleExpr)count (
VarExpr)variable (
str|VarExpr)
- Return type:
- 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.
- set_variables(*variables)[source]¶
Sets the free variables in a distribution.
- Parameters:
variables (
str) – The variables.- Return type:
- Returns:
The distribution with free variables variables.
- set_parameters(*parameters)[source]¶
Sets the parameters in a distribution.
- Parameters:
parameters (
str) – The parameters.- Return type:
- Returns:
The distribution with parameters parameters.
- approximate(threshold)[source]¶
Computes the approximation until the given threshold is reached (might not terminate).
- safe_subs(*parameters, fun=None)[source]¶
Substitution with checks for divisions by zero. Uses plain substitution if no pole is hit (see _hits_pole). Otherwise, converts to sympy and cancels the fraction if the function is rational, or takes the limit.
- filter(condition)[source]¶
Filters the distribution such that only the parts which satisfy the condition are left.
- Parameters:
condition (
VarExpr|BoolLitExpr|NatLitExpr|RealLitExpr|UnopExpr|BinopExpr|CategoricalExpr|SubstExpr|TickExpr|FunctionCallExpr|InferExpr|SampleExpr)- Return type:
- class SymenginePGF[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 + ….
- Parameters:
- Return type:
- 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 bernoulli(var, p)[source]¶
A bernoulli distribution with parameter p.
- Parameters:
- Return type:
- static poisson(var, lam)[source]¶
A poisson distribution with parameter lam.
- Parameters:
- 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.
- Parameters:
variables (
str|VarExpr)- Return type:
- static one(*variables)[source]¶
A distribution where all variables are initialized with 0.
- Parameters:
variables (
str|VarExpr)- Return type:
- static from_expr(expression, *variables, **kwargs)[source]¶
A distribution represented by the expression.
- Parameters:
expression (
str|VarExpr|BoolLitExpr|NatLitExpr|RealLitExpr|UnopExpr|BinopExpr|CategoricalExpr|SubstExpr|TickExpr|FunctionCallExpr|InferExpr|SampleExpr)- Return type: