The Cross-Entropy Method for either rare-event sampling or optimization.
Project description
The Cross Entropy Method
The Cross Entropy Method (CE or CEM) is an approach for optimization or rare-event sampling in a given class of distributions {D_p} and a score function R(x).
- In its sampling version, it is given a reference p0 and aims to sample from the tail of the distribution x ~ (D_p0 | R(x)<q), where q is defined as either a numeric value q or a quantile alpha (where q=q_alpha(R)).
- In its optimization version, it aims to find argmin_x{R(x)}.
The exact implementation of the CEM depends on the distributions family {D_p} as defined in the problem.
This repo provides a general implementation as an abstract class, where a concrete use requires writing a simple, small inherited class.
The attached tutorial.ipynb
provides a more detailed background on the CEM and on this package, along with usage examples.
Installation: pip install cross-entropy-method
.
CEM for sampling (left): the mean of the sample distribution (blue) aims to coincide with the mean of the tail of the original distribution (black). CEM for optimization (right): the mean of the sample distribution aims to be minimized. (images from tutorial.ipynb ) |
Supporting non-stationary score functions
On top of the standard CEM, we also support a non-stationary score function R. This affects the reference distribution of scores and thus the quantile threshold q (if specified as a quantile). Thus, we have to repeatedly re-estimate q, using importance-sampling correction to compensate for the CEM distributional shift.
In our separate work, we demonstrate the use of the CEM for the more realistic problem of sampling high-risk environment-conditions in risk-averse reinforcement learning. There, D_p determines the distribution of the environment-conditions, p0 corresponds to the original distribution (or test distribution), and R(x; agent) is the return function of the agent given the conditions x. Note that since the agent evolves with the training, the score function is indeed non-stationary.
Cite this repo
@misc{cross_entropy_method,
title={Cross Entropy Method with Non-stationary Score Function},
author={Ido Greenberg},
howpublished={\url{https://pypi.org/project/cross-entropy-method/}},
year={2022}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for cross-entropy-method-0.0.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab9d84e66540bd81b02c711236ec494ccb6f574ff15fd43e1ef6dd78ef439576 |
|
MD5 | 0bdebcc2f0b3abe8064be0e53008dde9 |
|
BLAKE2b-256 | 9ef24cda3079f4d0d9c4ac3d2a053c34b1e41c215703df348e86af74ee3db6bf |
Hashes for cross_entropy_method-0.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 662f0ff86563233c0f77f292ba0247a3584fcb1d15420ef6acc2c36a57993aec |
|
MD5 | 55a2eb7b4a2c3b7ffa11205a20553ef3 |
|
BLAKE2b-256 | 4ddd372bcc486e6da4a7ed79cb625e382cad6ce0cdc923c4f04223b2de531f81 |