Cross-entropy method

From HandWiki
Short description: Monte Carlo method for importance sampling and optimization

The cross-entropy (CE) method is a Monte Carlo method for importance sampling and optimization. It is applicable to both combinatorial and continuous problems, with either a static or noisy objective.

The method approximates the optimal importance sampling estimator by repeating two phases:[1]

  1. Draw a sample from a probability distribution.
  2. Minimize the cross-entropy between this distribution and a target distribution to produce a better sample in the next iteration.

Reuven Rubinstein developed the method in the context of rare-event simulation, where tiny probabilities must be estimated, for example in network reliability analysis, queueing models, or performance analysis of telecommunication systems. The method has also been applied to the traveling salesman, quadratic assignment, DNA sequence alignment, max-cut and buffer allocation problems.

Estimation via importance sampling

Consider the general problem of estimating the quantity

[math]\displaystyle{ \ell = \mathbb{E}_{\mathbf{u}}[H(\mathbf{X})] = \int H(\mathbf{x})\, f(\mathbf{x}; \mathbf{u})\, \textrm{d}\mathbf{x} }[/math],

where [math]\displaystyle{ H }[/math] is some performance function and [math]\displaystyle{ f(\mathbf{x};\mathbf{u}) }[/math] is a member of some parametric family of distributions. Using importance sampling this quantity can be estimated as

[math]\displaystyle{ \hat{\ell} = \frac{1}{N} \sum_{i=1}^N H(\mathbf{X}_i) \frac{f(\mathbf{X}_i; \mathbf{u})}{g(\mathbf{X}_i)} }[/math],

where [math]\displaystyle{ \mathbf{X}_1,\dots,\mathbf{X}_N }[/math] is a random sample from [math]\displaystyle{ g\, }[/math]. For positive [math]\displaystyle{ H }[/math], the theoretically optimal importance sampling density (PDF) is given by

[math]\displaystyle{ g^*(\mathbf{x}) = H(\mathbf{x}) f(\mathbf{x};\mathbf{u})/\ell }[/math].

This, however, depends on the unknown [math]\displaystyle{ \ell }[/math]. The CE method aims to approximate the optimal PDF by adaptively selecting members of the parametric family that are closest (in the Kullback–Leibler sense) to the optimal PDF [math]\displaystyle{ g^* }[/math].

Generic CE algorithm

  1. Choose initial parameter vector [math]\displaystyle{ \mathbf{v}^{(0)} }[/math]; set t = 1.
  2. Generate a random sample [math]\displaystyle{ \mathbf{X}_1,\dots,\mathbf{X}_N }[/math] from [math]\displaystyle{ f(\cdot;\mathbf{v}^{(t-1)}) }[/math]
  3. Solve for [math]\displaystyle{ \mathbf{v}^{(t)} }[/math], where
    [math]\displaystyle{ \mathbf{v}^{(t)} = \mathop{\textrm{argmax}}_{\mathbf{v}} \frac{1}{N} \sum_{i=1}^N H(\mathbf{X}_i)\frac{f(\mathbf{X}_i;\mathbf{u})}{f(\mathbf{X}_i;\mathbf{v}^{(t-1)})} \log f(\mathbf{X}_i;\mathbf{v}) }[/math]
  4. If convergence is reached then stop; otherwise, increase t by 1 and reiterate from step 2.

In several cases, the solution to step 3 can be found analytically. Situations in which this occurs are

  • When [math]\displaystyle{ f\, }[/math] belongs to the natural exponential family
  • When [math]\displaystyle{ f\, }[/math] is discrete with finite support
  • When [math]\displaystyle{ H(\mathbf{X}) = \mathrm{I}_{\{\mathbf{x}\in A\}} }[/math] and [math]\displaystyle{ f(\mathbf{X}_i;\mathbf{u}) = f(\mathbf{X}_i;\mathbf{v}^{(t-1)}) }[/math], then [math]\displaystyle{ \mathbf{v}^{(t)} }[/math] corresponds to the maximum likelihood estimator based on those [math]\displaystyle{ \mathbf{X}_k \in A }[/math].

Continuous optimization—example

The same CE algorithm can be used for optimization, rather than estimation. Suppose the problem is to maximize some function [math]\displaystyle{ S }[/math], for example, [math]\displaystyle{ S(x) = \textrm{e}^{-(x-2)^2} + 0.8\,\textrm{e}^{-(x+2)^2} }[/math]. To apply CE, one considers first the associated stochastic problem of estimating [math]\displaystyle{ \mathbb{P}_{\boldsymbol{\theta}}(S(X)\geq\gamma) }[/math] for a given level [math]\displaystyle{ \gamma\, }[/math], and parametric family [math]\displaystyle{ \left\{f(\cdot;\boldsymbol{\theta})\right\} }[/math], for example the 1-dimensional Gaussian distribution, parameterized by its mean [math]\displaystyle{ \mu_t\, }[/math] and variance [math]\displaystyle{ \sigma_t^2 }[/math] (so [math]\displaystyle{ \boldsymbol{\theta} = (\mu,\sigma^2) }[/math] here). Hence, for a given [math]\displaystyle{ \gamma\, }[/math], the goal is to find [math]\displaystyle{ \boldsymbol{\theta} }[/math] so that [math]\displaystyle{ D_{\mathrm{KL}}(\textrm{I}_{\{S(x)\geq\gamma\}}\|f_{\boldsymbol{\theta}}) }[/math] is minimized. This is done by solving the sample version (stochastic counterpart) of the KL divergence minimization problem, as in step 3 above. It turns out that parameters that minimize the stochastic counterpart for this choice of target distribution and parametric family are the sample mean and sample variance corresponding to the elite samples, which are those samples that have objective function value [math]\displaystyle{ \geq\gamma }[/math]. The worst of the elite samples is then used as the level parameter for the next iteration. This yields the following randomized algorithm that happens to coincide with the so-called Estimation of Multivariate Normal Algorithm (EMNA), an estimation of distribution algorithm.


// Initialize parameters
μ := −6
σ2 := 100
t := 0
maxits := 100
N := 100
Ne := 10
// While maxits not exceeded and not converged
while t < maxits and σ2 > ε do
    // Obtain N samples from current sampling distribution
    X := SampleGaussian(μ, σ2, N)
    // Evaluate objective function at sampled points
    S := exp(−(X − 2) ^ 2) + 0.8 exp(−(X + 2) ^ 2)
    // Sort X by objective function values in descending order
    X := sort(X, S)
    // Update parameters of sampling distribution via elite samples                  
    μ := mean(X(1:Ne))
    σ2 := var(X(1:Ne))
    t := t + 1
// Return mean of final sampling distribution as solution
return μ

Related methods

See also

Journal papers

  • De Boer, P.-T., Kroese, D.P., Mannor, S. and Rubinstein, R.Y. (2005). A Tutorial on the Cross-Entropy Method. Annals of Operations Research, 134 (1), 19–67.[1]
  • Rubinstein, R.Y. (1997). Optimization of Computer Simulation Models with Rare Events, European Journal of Operational Research, 99, 89–112.

Software implementations


  1. Rubinstein, R.Y. and Kroese, D.P. (2004), The Cross-Entropy Method: A Unified Approach to Combinatorial Optimization, Monte-Carlo Simulation, and Machine Learning, Springer-Verlag, New York ISBN:978-0-387-21240-1.