liveBook · Manning

Sampling

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

A sampling method that generates candidate points using random draws from a specified space or distribution.

Sampling generates candidate points from a search space or distribution. In population-based optimization, those points can form the initial population: a set of solutions to evaluate and improve. The choice of method affects how widely candidates are spread before the search begins. section 7.1

Choose an initialization method according to the coverage and cost the problem needs:

  • Pseudo-random sampling is inexpensive but offers moderate diversity. It is a simple starting point when broad, even coverage is not essential. section 7.1
  • Quasi-random sequences, including Sobol sequences, spread points more evenly through the sample space. Latin hypercube sampling divides the space into blocks and generates a point in each block. section 7.1
  • Box–Muller and central limit theorem sampling generate normally distributed values rather than simply spreading points across a bounded space. Match the distribution to the candidates you need. section 7.1

Compare 200 candidate points

For a two-variable problem bounded between 0 and 1, create a pymoo Problem, then call FloatRandomSampling()(problem, 200).get("X") to obtain candidate points. Replace FloatRandomSampling() with LHS() and plot both sets. Compare the gaps and dispersion, not just the number of points: both methods generate 200 candidates, but they can cover the space differently. section 7.1

Figure 7.2 Sampling methods for generating an initial population

Compare the plotted gaps and dispersion produced by six initialization methods; each point represents a candidate solution. section 7.1

Sampling also appears later in a genetic algorithm, but with a different job. Initial-population sampling creates candidates; parent selection chooses existing individuals to reproduce. Uniform random parent selection gives each of N individuals probability 1/N, regardless of fitness. In a Python implementation, random.sample(population, num_parents) makes that choice; roulette-wheel selection instead weights choices by fitness. Random survivor selection likewise draws N individuals for the next population. section 7.3.3 section 7.4 section 7.3.5

Initialize a ticket-pricing search

One binary genetic algorithm draws starting ticket prices as integers from 75 to 235, encodes them as eight-bit chromosomes, and then evaluates their profit. A pymoo version defines the same bounds and sets GA(sampling=FloatRandomSampling(), pop_size=100). The sampling setting creates starting candidates; crossover and mutation are separate settings for subsequent search. section 7.4

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

How deep it goes
Compares sampling methods by point dispersion, diversity, and cost, then demonstrates Python initialization without deriving convergence guarantees.
Examples
Plots candidate points from six methods and initializes ticket-pricing populations with Python and pymoo.
What it assumes
Assumes basic Python while illustrating search spaces, candidate populations, and sampling choices through code.
What you can do after
Apply it via NumPy or pymoo to create candidates and compare their coverage before optimization.
How it connects
Links sampling to population initialization, genetic algorithms, parent selection, survivor selection, and fitness-proportionate selection.

Also explained in

Compare how 23 books explain 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.