ArticleslgStudy

computer science

Cross-entropy method

Cross-entropy method is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Cross-entropy method rather than just read about it. In short: 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.

Key takeaways

  • Cross-entropy method belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Cross-entropy method to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Cross-entropy method from memory before moving on to harder problems.

Reference excerpt

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:

Draw a sample from a probability distribution. 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 ℓ=𝔼𝐮[H(𝐗)]=∫H(𝐱)f(𝐱;𝐮)d𝐱, where H is some performance function and f(𝐱;𝐮) is a member of some parametric family of distributions. Using importance sampling this quantity can be estimated as ℓ̂=1N∑i=1NH(𝐗i)f(𝐗i;𝐮)g(𝐗i), where 𝐗1,…,𝐗N is a random sample from g. For positive H, the theoretically optimal importance sampling density (PDF) is given by g∗(𝐱)=H(𝐱)f(𝐱;𝐮)/ℓ. This, however, depends on the unknown ℓ. 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 g∗.

Generic CE algorithm Choose initial parameter vector 𝐯(0); set t=1. Generate a random sample 𝐗1,…,𝐗N from f(⋅;𝐯(t−1)) Solve for 𝐯(t), where𝐯(t)=argmax𝐯1N∑i=1NH(𝐗i)f(𝐗i;𝐮)f(𝐗i;𝐯(t−1))log⁡f(𝐗i;𝐯) 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 f belongs to the natural exponential family When f is discrete with finite support When H(𝐗)=I{𝐱∈A} and f(𝐗i;𝐮)=f(𝐗i;𝐯(t−1)), then 𝐯(t) corresponds to the maximum likelihood estimator based on those 𝐗k∈A.

Continuous optimization—example The same CE algorithm can be used for optimization, rather than estimation. Suppose the problem is to maximize some function S, for example, S(x)=e−(x−2)2+0.8e−(x+2)2. To apply CE, one considers first the associated stochastic problem of estimating ℙ𝜽(S(X)≥γ) for a given level γ, and parametric family {f(⋅;𝜽)}, for example the 1-dimensional Gaussian distribution, parameterized by its mean μt and variance σt2 (so 𝜽=(μ,σ2) here). Hence, for a given γ, the goal is to find 𝜽 so that DKL(I{S(x)≥γ}‖f𝜽) 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 ≥γ. 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.

Pseudocode // 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 Simulated annealing Genetic algorithms Harmony search Estimation of distribution algorithm Tabu search Natural Evolution Strategy Ant colony optimization algorithms

See also Cross entropy Kullback–Leibler divergence Randomized algorithm Importance sampling

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 CEopt Matlab package CEoptim R package Novacta.Analytics .NET library

References

Worked examples

Example 1 — a first encounter with Cross-entropy method

Start with the simplest possible case. Write down what Cross-entropy method claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Cross-entropy method before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Cross-entropy method ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Cross-entropy method

In research
Cross-entropy method appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Cross-entropy method in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Cross-entropy method is common in secondary-school and first-year university syllabi. It links to neighbouring topics Heuristics, Machine learning, Monte Carlo methods, so understanding it makes those chapters shorter.
In everyday life
Look for Cross-entropy method outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Cross-entropy method” →

How to study Cross-entropy method in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Cross-entropy method means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Cross-entropy method out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Cross-entropy method in simple terms?

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.

Why does Cross-entropy method matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Cross-entropy method?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Cross-entropy method.

Tags

  • Heuristics
  • Machine learning
  • Monte Carlo methods
  • Optimization algorithms and methods

Keep exploring