metaheuristic_designer.operators.operator_functions.probability_distributions_factory module#

Factory and registry for probability distributions

create_prob_distribution(distribution_name, population_matrix=None, parameter_heuristic_fn=None, rng=None, **kwargs)[source]#

Instantiate a probability distribution by name.

Return type:

Distribution

Parameters:
distribution_namestr

Distribution key. Can use dot-notation (e.g., "scipy-univar.norm") or a short name ("norm") if unambiguous.

population_matrixMatrixLike

Population data used when automatic parameter estimation ("calculated") is requested.

parameter_heuristic_fnCallable, optional

An optional callable that overrides the registered heuristic for this call. If None, the registered heuristic (or a no-op) is used.

**kwargs

Parameters forwarded to the distribution constructor (e.g., loc, scale, min, max).

Returns:
Distribution

A callable distribution object ready for sampling.

Parameters:
  • distribution_name (str)

  • population_matrix (ndarray[tuple[int, int], floating] | ndarray[tuple[int, int], integer] | ndarray[tuple[int, int], uint8 | bool] | None)

  • parameter_heuristic_fn (Callable | None)

  • rng (int | Generator | None)

add_distribution_entry(distribution_class, distribution_name, registry='custom', param_processor=None, heuristic_fn=None)[source]#

Register a new probability distribution so that it can be created via create_prob_distribution().

Parameters:
distribution_classtype[Distribution]

A concrete Distribution subclass (or a callable that returns one). For SciPy distributions, pass the SciPy class directly (e.g., scipy.stats.norm); it will be wrapped automatically.

distribution_namestr

Key used to retrieve this distribution (e.g., "my_noise").

registrystr, optional

Sub-registry to add the distribution to. Currently supported values are "scipy-univar", "scipy-multivar", and "custom" (default). If the registry does not exist, it is created.

param_processorcallable, optional

A function that receives **kwargs and returns a modified dictionary before passing it to the distribution constructor. Useful for converting parameter names (see uniform_param_fix()).

heuristic_fncallable, optional

A function (population_matrix, **kwargs) -> kwargs that computes default parameter values when "calculated" is requested. If None (the default), the distribution does not support automatic parameter estimation.

Parameters:
  • distribution_class (Distribution)

  • distribution_name (str)

  • registry (str)

  • param_processor (Callable | None)

  • heuristic_fn (Callable | None)

list_distributions()[source]#

Return a list of all available distribution keys.

The keys are formatted as "registry.distribution_name" and can be passed directly to create_prob_distribution().

Return type:

list[str]

Returns:
list of str

Fully qualified distribution names.