liveBook · Manning

Sampling

As explained in Statistics Every Programmer Needs

Random sampling is a sampling procedure in which selections are made according to a probability mechanism rather than a deterministic choice.

Random sampling selects values through a probability mechanism rather than a deterministic rule. In Monte Carlo simulation, sampled values generate many possible scenarios whose aggregated outcomes approximate a probability distribution, especially when analytical solutions are impractical. section 9.0 section 9.1

A practical sampling workflow for Monte Carlo analysis is:

  • Define a mathematical model containing the relevant variables and their relationships. section 9.1
  • Specify probability distributions for uncertain variables, including their possible values and likelihoods. section 9.1
  • Sample values repeatedly to create trials, with each trial representing one possible outcome. section 9.3 section 9.1
  • Aggregate and analyze the trials as a probability distribution, checking simulated behavior against known inputs or theoretical results. section 9.3 section 9.4.1

Staffing and stock-price uncertainty

For a call center, sampling absentee counts supports an overstaffing decision by exposing likely staffing requirements and the risk of understaffing. For stock prices, sampling from a distribution of historical price changes produces many possible future closing prices and supports analysis of mean, standard deviation, range, and investment risk. section 9.3 section 9.5 section 9.1

Figure 9.3 Probability distribution from 500 Monte Carlo simulations closely resembling a theoretical Poisson distribution with a rate parameter of 2. The labels atop the bars represent the percentage of trials that resulted in each unique random variable between 0 and 7. No trials result in a k value of 8, consistent with the low theoretical probability of such an outcome.
figure

A bar chart of 500 sampled Poisson outcomes shows how random sampling approximates the theoretical distribution, including small deviations and rare outcomes. section 9.4.1

How Statistics Every Programmer Needs covers it

How deep it goes
Explains the simulation workflow from model definition through repeated trials and result analysis, but does not provide implementation code.
Examples
Demonstrates absenteeism counts, Poisson outcomes, call-center overstaffing, and simulated future stock prices.
What it assumes
Assumes a defined mathematical model and probability distributions while introducing discrete and continuous random variables.
What you can do after
Apply random sampling to construct scenarios, compare simulated and theoretical distributions, and interpret uncertainty for operational or investment decisions.
How it connects
Connects random sampling with Monte Carlo simulations, probability distributions, discrete random variables, continuous random variables, and risk analysis.

Also explained in

Compare how 23 books explain sampling →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.