Utilities#

Numerical helpers shared by every setting.

Tie-breaking selection#

utils.randmax

Index of a maximum of A, breaking ties uniformly at random.

utils.randmin

Index of a minimum of A, breaking ties uniformly at random.

utils.allmax

Maximum of a together with every index attaining it.

Divergences#

Parametric divergences for the usual one-parameter exponential families, plus the non-parametric \(K_{\inf}\) used by the batched IMED variants. Pick the one matching your rewards — an index algorithm is asymptotically optimal only for the right divergence.

utils.klBern

Kullback-Leibler divergence between two Bernoulli distributions.

utils.klGauss

Kullback-Leibler divergence between two Gaussians of equal variance.

utils.klPoisson

Kullback-Leibler divergence between two Poisson distributions.

utils.klExp

Kullback-Leibler divergence between two exponential distributions.

utils.KLinf_threshold

Non-parametric divergence \(K_{\inf}\) between an empirical distribution and the set of distributions with mean above a threshold, evaluated using the concave dual.

Sampling#

utils.categorical_sample

Draw one index from a categorical distribution.

utils.Dirac

Deterministic distribution concentrated on a single value.

Setting validation#

Checks that a setting folder follows the layout described in Contributing.

validator.validate_setting

Validate a complete setting folder.

validator.validate_structure

Check required files and folders.

validator.validate_environment

Check Environment class and API.

validator.validate_agent

Check Agent class.

validator.validate_interaction

Check Interaction class and API.

validator.validate_environment_yaml

Validate envs/environments.yaml files.

validator.load_module

Import a python module from a file path.

validator.report

Print one check result and pass its verdict through.