computation

Computation Primitives and Conversions

Core building blocks for computing distribution characteristics and conversions between them (e.g., PDF to CDF, CDF to PPF).

class pysatl_core.distributions.computation.Computation(*args, **kwargs)[source]

Bases: Protocol, Generic

Protocol for computations that evaluate a single characteristic.

target

Name of the characteristic this computation produces.

Type:

str

property target: GenericCharacteristicName
__init__(*args, **kwargs)
class pysatl_core.distributions.computation.AnalyticalComputation(target, func)[source]

Bases: Generic

Analytical computation provided directly by a distribution.

Parameters:
  • target (str) – Characteristic name (e.g., “pdf”, “cdf”).

  • func (ComputationFunc[In, Out]) – Analytical function that computes the characteristic.

target: TypeAliasType
func: GenericAlias[TypeVar(In), TypeVar(Out)]
__call__(*args, **options)[source]

Evaluate the analytical function.

Return type:

typing.Any

Parameters:
__init__(target, func)
Parameters:
  • target (GenericCharacteristicName)

  • func (ComputationFunc[Any, Any])

Return type:

None

class pysatl_core.distributions.computation.FittedComputationMethod(target, sources, func)[source]

Bases: Generic

Fitted conversion method ready for use.

Parameters:
  • target (str) – Destination characteristic name.

  • sources (Sequence[str]) – Source characteristic names (typically length 1 for unary conversions).

  • func (ComputationFunc[In, Out]) – Callable implementing the fitted conversion.

target: TypeAliasType
sources: Sequence[TypeAliasType]
func: GenericAlias[TypeVar(In), TypeVar(Out)]
__call__(*args, **options)[source]

Evaluate the fitted conversion.

Return type:

typing.Any

Parameters:
__init__(target, sources, func)
Parameters:
  • target (GenericCharacteristicName)

  • sources (Sequence[GenericCharacteristicName])

  • func (ComputationFunc[Any, Any])

Return type:

None

class pysatl_core.distributions.computation.ComputationMethod(target, sources, fitter=None, evaluator=None)[source]

Bases: Generic

Factory for creating fitted computation methods.

This class represents a conversion method that needs to be fitted to a specific distribution before it can be used.

Parameters:
  • target (str) – Destination characteristic name.

  • sources (Sequence[str]) – Source characteristic names (typically length 1 for unary conversions).

  • fitter (Fitter[In, Out] | None) – Function that fits the computation method to a distribution. If provided, the method is considered cacheable (fitting may perform expensive precomputation).

  • evaluator (Evaluator[In, Out] | None) – Direct evaluator that performs the computation in one step, without a separate fitting stage. If provided, the method is considered non-cacheable at the strategy level.

target: TypeAliasType
sources: Sequence[TypeAliasType]
fitter: GenericAlias[TypeVar(In), TypeVar(Out)] | None
evaluator: GenericAlias[TypeVar(In), TypeVar(Out)] | None
__init__(target, sources, fitter=None, evaluator=None)
Parameters:
  • target (GenericCharacteristicName)

  • sources (Sequence[GenericCharacteristicName])

  • fitter (Fitter[Any, Any] | None)

  • evaluator (Evaluator[Any, Any] | None)

Return type:

None

property cacheable: bool

Whether it makes sense to cache the prepared method at strategy level.

prepare(distribution, **options)[source]

Prepare a callable method for a specific distribution. :rtype: FittedComputationMethod[typing.Any, typing.Any]

  • If fitter is provided, run the fitting stage and return the fitted method.

  • If evaluator is provided, bind the distribution and return a lightweight fitted wrapper.

Parameters:
Return type:

FittedComputationMethod[Any, Any]

evaluate(distribution, *args, **options)[source]

Evaluate direct computation methods.

This is only available for methods defined via evaluator.

Return type:

typing.Any

Parameters:
fit(distribution, **options)[source]

Fit the computation method to a specific distribution.

Parameters:
  • distribution (Distribution) – Distribution to fit the computation method to.

  • **options (Any) – Additional options passed to the fitter.

Returns:

Fitted method ready for evaluation.

Return type:

FittedComputationMethod

__call__(distribution, *args, **options)[source]

Fit if possible and then evaluate

Return type:

typing.Any

Parameters: