inferlo.FunctionFactor

class inferlo.FunctionFactor[source]

A factor given explicitly by function.

__init__(model: GraphModel, var_idx: List[int], func: Callable[[List[float]], float])[source]

Create function factor.

Parameters:
  • model – Graphical model this factor belongs to.

  • var_idx – Indices of variables in the model, on which this factor depends.

  • func – Function of this factor (as Python callable).

Methods

__init__(model, var_idx, func)

Create function factor.

apply_function(func)

Returns factor func(g(x)), where g(x) is given factor.

clone(new_model)

Creates the same factor, but pointing to new model.

combine_factors(factor1, factor2, func)

Returns a factor which is a function of other 2 factors.

combine_with(other, func)

Returns factor func(g(x), other), where g(x) is given factor.

cos()

Sine of this factor.

exp()

Exponent of this factor.

get_name()

Name of this factor.

is_discrete()

Whether all variables in the factor are discrete.

sin()

Sine of this factor.

value(values)

Value of function inside this factor in given point.

apply_function(func: Callable[[float], float])[source]

Returns factor func(g(x)), where g(x) is given factor.

static combine_factors(factor1: FunctionFactor, factor2: FunctionFactor, func: Callable[[float, float], float]) FunctionFactor[source]

Returns a factor which is a function of other 2 factors.

combine_with(other: Any, func: Callable[[float, float], float])[source]

Returns factor func(g(x), other), where g(x) is given factor.

other may be a number, variable or another factor.

cos()[source]

Sine of this factor.

exp()[source]

Exponent of this factor.

sin()[source]

Sine of this factor.

value(values: List[float])[source]

Value of function inside this factor in given point.