liveBook · Manning

Box-Muller transform

As explained in Optimization Algorithms: AI techniques for design, planning, and control problems

A transformation that converts pairs of independent uniform random variables into pairs of independent standard normal random variables.

The Box-Muller transform converts pairs of independent uniform random variables into pairs of independent standard normal random variables. In population-based metaheuristics, it provides a two-dimensional Gaussian sampling method for generating initial solutions. section 7.1

A NumPy implementation follows two parallel calculations:

Sampling an initial population

With N = 200, NumPy generates two length-N uniform arrays and produces P_BM_x and P_BM_y. A scatter plot compares their distribution with pseudo-random, central-limit, Sobol, and Latin-hypercube sampling. section 7.1

u1 = np.random.uniform(size=(N))                        #1
u2 = np.random.uniform(size=(N))                        #1
  
P_BM_x = np.sqrt(-2*np.log(u1))*np.cos(2*math.pi*u2)    #2
P_BM_y = np.sqrt(-2*np.log(u1))*np.sin(2*math.pi*u2)    #2

Inspect the direct NumPy formulas for both Gaussian coordinates. section 7.1

How Optimization Algorithms: AI techniques for design, planning, and control problems covers it

How deep it goes
Defines the transformation and gives executable formulas, but stops short of deriving them mathematically.
Examples
Uses NumPy arrays of 200 samples and scatter plots to compare Box-Muller with five population-initialization strategies.
What it assumes
Assumes uniform random sampling and basic Python, NumPy, logarithm, square-root, and trigonometric operations.
What you can do after
Apply it via NumPy to generate paired standard-normal samples for population initialization.
How it connects
Connects uniform random variables with normal distributions, central limit theorem sampling, Sobol sequences, and Latin hypercube sampling.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Optimization Algorithms: AI techniques for design, planning, and control problems. The section links point to the parts of the book it draws on.