100 Exercises / Probability Statistics / 100 Exercises on Probability and Statistical Theory
Sample Size and Manufacturing KPIs: Limit Theorems and Probability Bounds
Use limit theorems and concentration inequalities in Python to compare sample sizes, estimation errors, and probability bounds for manufacturing KPIs.
Sample Size and Manufacturing KPIs: Limit Theorems and Probability Bounds
On the manufacturing floor, we assess daily average defect rates and average cycle times to determine process stoppages, additional inspections, and capital investments. However, the average of a few data points tends to be random, and safety-side evaluations without assuming distribution tend to be conservative. This article uses a fictional precision parts factory as a subject and connects No.071〜No.080(Limit theorem) to the determination of required sample numbers, management thresholds, and estimation accuracy.
About this material
This article adapts a notebook used in corporate training by Surikobo or its representative, Hiroshi Wayama, and is published with the client company’s permission. All data listed is fictional and has no relation whatsoever to real companies, factories, or figures.
Introduction: Practical Challenges in Manufacturing Covered in This Article
The setting is a fictional factory that processes precision shafts for automobiles. The quality assurance department estimates process defect rates from spot checks, while the production management department monitors cycle times and daily losses. At the management meeting, explanations for the following questions are necessary.
- How many lots should be observed to treat the average KPI as a stable value?
- Even if the original data is distorted, is it okay to approximate the sample mean normally?
- Whether standardization and error evaluation are possible even if the population variance is unknown
- In situations where distribution cannot be definitively determined, how much can threshold exceedance be evaluated as safe?
- How to convert errors in defect rate estimates into errors in delivery quantities and quality loss
Common situations on site
At the beginning of the month’s meeting, you may request a process stop by saying “the average of the last 10 lots has deteriorated,” while another report might report that “if the average of 100 lots is average, there is no problem.” Also, only the defect rate of 3% is shared, and the sample size of 100 or 10,000 samples may be omitted.
Even if the average value is the same, the sample size will differ in accuracy. Conversely, using only extremely conservative upper bounds for safety purposes can lead to over-inspection and overstocking. You need to organize what is known about the number of datasets, variables, independence, and variance, and choose a theory that fits your purpose.
Why is this issue so difficult to judge?
Many limit theorems describe properties when the sample size is sufficiently large, but the size of the enough varies depending on the skewness of the original distribution, the weight of the tails, autocorrelation, and the accuracy of the determination. is not a uniform rule that can always be approximated normally.
Furthermore, the inequalities of Chebyshev, Markov, Chernoff, Hoeffding, and others differ in the required assumptions and the sharpness of the upper bound. The upper bound is not the actual probability itself, but a guarantee that “under assumption, it will not exceed this.” A practical focus is to distinguish between guaranteed and predicted values and to evaluate the costs associated with conservatism.
Overview of the exercises
| No. | Theme | Judgment in the manufacturing industry |
|---|---|---|
| 071 | Law of large numbers | Confirm observational surveys until cumulative mean stabilizes |
| 072 | central limit theorem | Approximate the error of the sample mean from distorted individual record data |
| 073 | Slutsky’s theorem | Replace unknown population standard deviations with sample standard deviations |
| 074 | delta method | Convert the error in the defect rate into the error in the required number of inputs |
| 075 | Chebyshev’s inequality | Suppressing deviation probability from above using only average and variance |
| 076 | Markov’s inequality | Assessing the risk of high costs from non-negative quality loss |
| 077 | Chernoff Bound | Evaluate the upper probability of the number of binomial defects exponentially |
| 078 | Hoeffding inequality | Linking the mean error of bounded test results to sample size |
| 079 | Concentration Inequality | Comparing the assumptions of multiple concentration inequalities and conservatism |
| 080 | asymptotic normality | Checking the distribution of defect rate estimators and the accuracy of confidence intervals |
Preparing the Python environment
We use NumPy, pandas, SciPy, and Matplotlib. It does not depend on external data, and random number seeds are fixed to 20260711. Theoretical values and simulations are displayed side by side, and approximate, upper bound, and actual measurement frequencies are not confused.
Start each article in a fresh notebook kernel and run [IN: 1] onward in order. Each result appears under the matching [OUT: 1] number. Expand the setup sections to view their code. Outputs are example runs; formatting and final digits may vary with library versions.
Setup: libraries, display settings, and random seed (expand)
# Run cells in order. Set plotting defaults and a reproducible random seed.
import platform
import sys
import japanize_matplotlib # noqa: Enable F401 Japanese font
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import scipy
from IPython.display import display
from scipy.stats import binom, norm
SEED = 20260711
rng = np.random.default_rng(SEED)
plt.rcParams["figure.figsize"] = (8, 4.5)
plt.rcParams["axes.axisbelow"] = True
print(f"Python : {sys.version.split()[0]}")
print(f"NumPy : {np.__version__}")
print(f"pandas : {pd.__version__}")
print(f"SciPy : {scipy.__version__}")
print(f"Matplotlib : {matplotlib.__version__}")
print(f"Platform : {platform.platform()}")
Python : 3.11.9
NumPy : 1.26.4
pandas : 2.2.2
SciPy : 1.13.1
Matplotlib : 3.9.2
Platform : macOS-26.5.2-arm64-arm-64bit
Generating synthetic data
For 2,400 lots, it generates inspection numbers, defect counts, average cycle times, and quality losses. Defect rates involve product differences and daily fluctuations, while quality loss is distributed with long tails to the right. For sections where the subsequent theorem is clearly confirmed, separate iterative simulations with fixed conditions are also conducted.
Setup: generate synthetic data (expand)
# Generate synthetic data for the exercises; these are not real factory records.
n_lots = 2_400
products = rng.choice(
["ProductsA", "ProductsB", "ProductsC"], n_lots, p=[0.50, 0.30, 0.20]
)
base_p = (
pd.Series(products)
.map({"ProductsA": 0.018, "ProductsB": 0.030, "ProductsC": 0.048})
.to_numpy()
)
inspection_n = rng.choice([80, 100, 120], n_lots, p=[0.2, 0.6, 0.2])
lot_p = np.clip(base_p * rng.lognormal(0, 0.18, n_lots), 0.002, 0.15)
defects = rng.binomial(inspection_n, lot_p)
cycle = rng.lognormal(np.log(61), 0.10, n_lots)
quality_loss = 6_000 + 9_000 * defects + rng.lognormal(np.log(8_000), 0.75, n_lots)
df = pd.DataFrame(
{
"lotID": [f"L{i:04d}" for i in range(1, n_lots + 1)],
"Products": products,
"number_of_inspections": inspection_n,
"number_of_defects": defects,
"defect_rate": defects / inspection_n,
"average_cycle_time_sec": cycle,
"quality_loss_yen": quality_loss,
}
)
display(df.head())
display(
df.groupby("Products", observed=True)
.agg(
lot_size=("lotID", "size"),
average_defect_rate=("defect_rate", "mean"),
average_cycle_time_sec=("average_cycle_time_sec", "mean"),
average_quality_loss_yen=("quality_loss_yen", "mean"),
)
.round(3)
)
| lotID | Products | number_of_inspections | number_of_defects | defect_rate | average_cycle_time_sec | quality_loss_yen | |
|---|---|---|---|---|---|---|---|
| 0 | L0001 | ProductsA | 100 | 1 | 0.01 | 60.847742 | 18462.889513 |
| 1 | L0002 | ProductsC | 100 | 5 | 0.05 | 75.243633 | 66797.020735 |
| 2 | L0003 | ProductsB | 100 | 3 | 0.03 | 62.494952 | 40788.067078 |
| 3 | L0004 | ProductsB | 100 | 2 | 0.02 | 56.958848 | 31125.459117 |
| 4 | L0005 | ProductsC | 100 | 5 | 0.05 | 59.491457 | 63804.395203 |
| lot_size | average_defect_rate | average_cycle_time_sec | average_quality_loss_yen | |
|---|---|---|---|---|
| Products | ||||
| ProductsA | 1228 | 0.018 | 61.560 | 33018.239 |
| ProductsB | 689 | 0.030 | 60.998 | 44068.843 |
| ProductsC | 483 | 0.048 | 61.182 | 59565.582 |
No.071: Law of Large Numbers
Practical meaning
The law of large numbers shows that when observations follow the same distribution independently, the sample mean approaches the population mean. Seeing the cumulative average of daily quality loss stabilize helps explain the danger of setting an annual budget based solely on a few days.
Definitions and calculations
For an independent and identically distributed random variable with an expected value , the sample mean
converges probabilistically to . This does not mean that the error in the average will always decrease monotonically; rather, it tends to remain stable over the long term while fluctuating along the way.
Check with Python
x = df["quality_loss_yen"].to_numpy()
running_mean = np.cumsum(x) / np.arange(1, len(x) + 1)
reference_mean = x.mean()
checkpoints = [10, 30, 100, 300, 1_000, 2_400]
lln_table = pd.DataFrame(
{
"Number of Observation Lots": checkpoints,
"cumulative_average_loss_yen": [running_mean[i - 1] for i in checkpoints],
"difference_from_the_average_over_the_entire_period_pct": [
100 * (running_mean[i - 1] / reference_mean - 1) for i in checkpoints
],
}
)
display(lln_table.round(2))
plt.plot(np.arange(1, len(x) + 1), running_mean, label="Cumulative mean")
plt.axhline(reference_mean, color="tab:red", linestyle="--", label="2,400Lot Average")
plt.title("Number of Observed Lots and Cumulative Average Quality Loss")
plt.xlabel("Number of Observation Lots")
plt.ylabel("Cumulative Average Quality Loss (Yen/Lot)")
plt.grid(alpha=0.3)
plt.legend()
plt.tight_layout()
plt.show()
| Number of Observation Lots | cumulative_average_loss_yen | difference_from_the_average_over_the_entire_period_pct | |
|---|---|---|---|
| 0 | 10 | 45265.58 | 8.99 |
| 1 | 30 | 41531.88 | -0.00 |
| 2 | 100 | 41717.51 | 0.44 |
| 3 | 300 | 41504.03 | -0.07 |
| 4 | 1000 | 40694.68 | -2.02 |
| 5 | 2400 | 41533.34 | -0.00 |

Reading the results
The initial cumulative average moves due to the influence of high-loss lots, but as the number of observations increases, it stabilizes around the 2,400-lot average. However, the law of large numbers does not guarantee that the current average will remain unchanged in the future. If equipment modifications, product compositions, or inspection standards change, the assumption of an unchanged distribution is undermined. In addition to cumulative averages, it is necessary to manage stratification, time series, and process change points.
The reference line is the mean of all 2,400 observations, not a known population mean. The final cumulative mean equals it by construction; this graph does not prove the law of large numbers.
No.072: Central Limit Theorem
Practical meaning
Even if individual cycle times are skewed to the right, the average of multiple lots approaches a normal distribution when the sample size increases. This allows us to explain the margin of error in the weekly average and the margin of capacity planning using a normal approximation.
Definitions and calculations
In an independent identically distributed sample with an average and finite variance ,
This holds. Since the standard deviation of the sample mean is , to halve the error, the sample size should generally be quadrupled.
Check with Python
clt_rng = np.random.default_rng(SEED + 72)
mu_log, sigma_log = np.log(61), 0.28
population_mean = np.exp(mu_log + sigma_log**2 / 2)
population_sd = np.sqrt((np.exp(sigma_log**2) - 1) * np.exp(2 * mu_log + sigma_log**2))
n_reps = 8_000
fig, axes = plt.subplots(1, 3, figsize=(13, 3.8))
clt_rows = []
for ax, n in zip(axes, [5, 30, 100]):
means = clt_rng.lognormal(mu_log, sigma_log, size=(n_reps, n)).mean(axis=1)
xs = np.linspace(means.min(), means.max(), 300)
ax.hist(means, bins=40, density=True, alpha=0.65, color="tab:blue")
ax.plot(
xs, norm.pdf(xs, population_mean, population_sd / np.sqrt(n)), color="tab:red"
)
ax.set_title(f"Sample mean (n={n})")
ax.set_xlabel("Average cycle time (seconds)")
ax.set_ylabel("density")
ax.grid(alpha=0.3)
clt_rows.append([n, means.mean(), means.std(ddof=1), population_sd / np.sqrt(n)])
plt.tight_layout()
plt.show()
display(
pd.DataFrame(
clt_rows,
columns=[
"n",
"mean of the sample",
"Actual measurement of sample meansSD",
"theoretical standard error",
],
).round(3)
)

| n | mean of the sample | Actual measurement of sample meansSD | theoretical standard error | |
|---|---|---|---|---|
| 0 | 5 | 63.403 | 8.042 | 8.102 |
| 1 | 30 | 63.406 | 3.315 | 3.308 |
| 2 | 100 | 63.500 | 1.829 | 1.812 |
Reading the results
Although the original log-normal distribution is skewed to the right, the sample mean distribution approaches a bilaterally symmetrical normal curve as increases, and the measured SD also matches the theoretical standard error. In small samples or extremely heavy tailed distributions, approximation may be slow. Also, if there is autocorrelation in consecutive lots, the information does not increase as much as the apparent sample size, so the time series structure is also checked.
No.073: Slutsky’s Theorem
Practical meaning
The central limit theorem yields the population standard deviation , but it is unknown in practice. By Slutsky’s theorem, even if you convert to the sample standard deviation , which is a consistent estimator, it can be explained that large samples approach the same standard normal distribution.
Definitions and calculations
, , then under continuous arithmetic operations, the combined quantities also converge to the corresponding distribution. Therefore,
Note that this is not a theorem that asserts precision with finite samples.
Check with Python
sl_rng = np.random.default_rng(SEED + 73)
n, reps = 80, 10_000
samples = sl_rng.lognormal(mu_log, sigma_log, size=(reps, n))
means = samples.mean(axis=1)
s = samples.std(axis=1, ddof=1)
z_known = np.sqrt(n) * (means - population_mean) / population_sd
z_estimated = np.sqrt(n) * (means - population_mean) / s
summary = pd.DataFrame(
{
"standardization": ["Population SD", "Sample SD", "Standard normal"],
"average": [z_known.mean(), z_estimated.mean(), 0],
"standard_deviation": [z_known.std(ddof=1), z_estimated.std(ddof=1), 1],
"2.5%point": [
np.quantile(z_known, 0.025),
np.quantile(z_estimated, 0.025),
norm.ppf(0.025),
],
"97.5%point": [
np.quantile(z_known, 0.975),
np.quantile(z_estimated, 0.975),
norm.ppf(0.975),
],
}
)
display(summary.round(3))
xs = np.linspace(-4, 4, 300)
plt.hist(
z_estimated, bins=50, density=True, alpha=0.65, label="Standardized using sample SD"
)
plt.plot(xs, norm.pdf(xs), color="tab:red", label="standard normal density")
plt.title(
"Standardization with the Sample Standard Deviation"
)
plt.xlabel("Standardized statistic")
plt.ylabel("density")
plt.grid(alpha=0.3)
plt.legend()
plt.tight_layout()
plt.show()
| standardization | average | standard_deviation | 2.5%point | 97.5%point | |
|---|---|---|---|---|---|
| 0 | Population SD | -0.008 | 1.002 | -1.95 | 1.998 |
| 1 | Sample SD | -0.058 | 1.027 | -2.19 | 1.873 |
| 2 | Standard normal | 0.000 | 1.000 | -1.96 | 1.960 |

Reading the results
The statistics standardized by sample SD also closely follow the standard normal distribution, with an average of 0 and a standard deviation of 1. This is the theoretical basis for estimating unknown variation from actual results to create standard errors. However, with small samples, substitution error cannot be ignored, so methods suitable for finite samples are prioritized, such as using a t-distribution for the mean of a normal population.
No.074: Delta Method
Practical meaning
There are situations where you want to report the expected number of inputs to deliver 1,000 good products, not the defect rate itself. The delta method approximately propagates the error in the estimated defect rate to the error of the KPI converted nonlinearly.
Definitions and calculations
If and is differentiable at ,
Here is the expected production count needed for 1,000 good units, and . The calculation propagates uncertainty in the estimated rate; it does not include the additional randomness of future production.
Check with Python
delta_rng = np.random.default_rng(SEED + 74)
p_true, n, reps = 0.04, 800, 50_000
p_hat = delta_rng.binomial(n, p_true, reps) / n
required_input = 1_000 / (1 - p_hat)
g_true = 1_000 / (1 - p_true)
se_p = np.sqrt(p_true * (1 - p_true) / n)
delta_se = 1_000 / (1 - p_true) ** 2 * se_p
delta_table = pd.DataFrame(
{
"indicator": [
"ConversionKPIAverage",
"ConversionKPIStandard deviation",
"95%lower_limit",
"95%upper",
],
"Simulation": [
required_input.mean(),
required_input.std(ddof=1),
*np.quantile(required_input, [0.025, 0.975]),
],
"delta method": [
g_true,
delta_se,
g_true - 1.96 * delta_se,
g_true + 1.96 * delta_se,
],
}
)
display(delta_table.round(2))
plt.hist(required_input, bins=45, density=True, alpha=0.65, label="Simulation")
xs = np.linspace(required_input.min(), required_input.max(), 300)
plt.plot(
xs,
norm.pdf(xs, g_true, delta_se),
color="tab:red",
label="Delta Method Normal Approximation",
)
plt.title("Propagate defect rate estimation errors to the required input quantity")
plt.xlabel("Expected units needed for 1,000 good units")
plt.ylabel("density")
plt.grid(alpha=0.3)
plt.legend()
plt.tight_layout()
plt.show()
| indicator | Simulation | delta method | |
|---|---|---|---|
| 0 | ConversionKPIAverage | 1041.78 | 1041.67 |
| 1 | ConversionKPIStandard deviation | 7.50 | 7.52 |
| 2 | 95%lower_limit | 1028.28 | 1026.93 |
| 3 | 95%upper | 1056.80 | 1056.40 |

Reading the results
The delta method’s standard error and 95% range are values close to those in iterative simulations. By not only estimating the defect rate points but also adding a range to the required input quantity, you can discuss material arrangements and capacity availability. In regions where the transformation bends sharply, near boundaries, and small samples, normal approximations tend to break down, so bootstraps or direct simulations are compared to this.
No.075: Chebyshev’s Inequality
Practical meaning
Even if you cannot identify the distribution pattern of process KPIs, knowing the mean and finite variance helps suppress the probability of deviating significantly from the mean. It can be used for safety side evaluations during periods when the basis for distribution assumptions is weak in new processes.
Definitions and calculations
For any random variable with an average and standard deviation , if is
No distributional shape is assumed, but the upper bound is often conservative. The calculation below uses the sample mean and variance with denominator , so it verifies the inequality for the empirical distribution that gives equal weight to each observation. It is not a guarantee for an unknown future population.
Check with Python
loss = df["quality_loss_yen"].to_numpy()
mu_loss, sd_loss = loss.mean(), loss.std(ddof=0)
k_values = np.array([1.5, 2.0, 2.5, 3.0, 4.0])
empirical = np.array([np.mean(np.abs(loss - mu_loss) >= k * sd_loss) for k in k_values])
cheb = 1 / k_values**2
cheb_table = pd.DataFrame(
{"k": k_values, "Measured Deviation Rate": empirical, "Chebyshev bound": cheb}
)
display(cheb_table.round(4))
plt.plot(k_values, empirical, marker="o", label="Measured Deviation Rate")
plt.plot(k_values, cheb, marker="s", label="Chebyshev bound")
plt.title("Probability of a Deviation of at Least k Standard Deviations")
plt.xlabel("k(Multiple of the standard deviation)")
plt.ylabel("Probability and upper bound")
plt.grid(alpha=0.3)
plt.legend()
plt.tight_layout()
plt.show()
| k | Measured Deviation Rate | Chebyshev bound | |
|---|---|---|---|
| 0 | 1.5 | 0.0996 | 0.4444 |
| 1 | 2.0 | 0.0450 | 0.2500 |
| 2 | 2.5 | 0.0208 | 0.1600 |
| 3 | 3.0 | 0.0100 | 0.1111 |
| 4 | 4.0 | 0.0025 | 0.0625 |

Reading the results
At all thresholds, the actual deviation rate is below the Chebyshev upper bound, but the difference is large, and using the upper bound as a prediction overestimates risk. This inequality is suitable for creating a “minimum guarantee.” In practice, after obtaining sufficient histories, distribution fitting and resampling are used together, and additional inspections and inventory costs due to conservatism are also clearly indicated.
No.076: Markov’s Inequality
Practical meaning
Non-negative KPIs such as quality loss, downtime, and rework hours can create an upper bound for high costs and long hours beyond the average. It is effective when setting a provisional risk limit on a new line without detailed distribution.
Definitions and calculations
For non-negative random variables and ,
is Markov’s inequality. Since only non-negativity is used, the range of application is broad, but if the upper bound exceeds 1, it is rounded down to the trivial upper bound 1.
Check with Python
thresholds = np.array([40_000, 60_000, 80_000, 120_000, 180_000])
markov_emp = np.array([(loss >= a).mean() for a in thresholds])
markov_bound = np.minimum(1, mu_loss / thresholds)
markov_table = pd.DataFrame(
{
"loss_threshold_yen": thresholds,
"Observed exceedance frequency": markov_emp,
"Markov bound": markov_bound,
"Ceiling of expected exceedance bound per 1000 lots": np.ceil(
1_000 * markov_bound
).astype(int),
}
)
display(markov_table.round(4))
plt.plot(thresholds, markov_emp, marker="o", label="Observed exceedance frequency")
plt.plot(thresholds, markov_bound, marker="s", label="Markov bound")
plt.title("Quality loss threshold exceeding rate and Markov upper bound")
plt.xlabel("Quality-loss threshold (yen per lot)")
plt.ylabel("Excess Probability & Upper Bound")
plt.grid(alpha=0.3)
plt.legend()
plt.tight_layout()
plt.show()
| loss_threshold_yen | Observed exceedance frequency | Markov bound | Ceiling of expected exceedance bound per 1000 lots | |
|---|---|---|---|---|
| 0 | 40000 | 0.4483 | 1.0000 | 1000 |
| 1 | 60000 | 0.1721 | 0.6922 | 693 |
| 2 | 80000 | 0.0542 | 0.5192 | 520 |
| 3 | 120000 | 0.0029 | 0.3461 | 347 |
| 4 | 180000 | 0.0000 | 0.2307 | 231 |

Reading the results
The Markov bound exceeds the observed tail frequency for this empirical distribution. The count column is the ceiling of an upper bound on the expected number of exceedances in 1,000 lots from that distribution; it is not a maximum possible count. Substituting an estimated mean for an unknown population mean does not by itself guarantee a future tail probability. Non-negativity is essential.
No.077: Chernoff Bound
Practical meaning
For lots assuming a fixed defect rate, the probability that the number of defects far exceeds the expected value is evaluated exponentially as an upper bound. You can identify risk orders at alarm thresholds without running a full simulation.
Definitions and calculations
, , and The multiplicative Chernoff bound is
Because it uses the exponential moment, it rapidly decreases compared to the general upper bound of just average and variance.
Check with Python
n, p = 1_000, 0.02
mu = n * p
thresholds = np.array([25, 30, 35, 40, 45])
deltas = thresholds / mu - 1
exact_tail = binom.sf(thresholds - 1, n, p)
chernoff = (np.exp(deltas) / (1 + deltas) ** (1 + deltas)) ** mu
chernoff_table = pd.DataFrame(
{
"alarm_threshold_number_of_defects": thresholds,
"How many times higher than expectations?": thresholds / mu,
"Exact Probability of the Binomial Distribution": exact_tail,
"Chernoff bound": chernoff,
}
)
display(chernoff_table)
plt.semilogy(
thresholds,
exact_tail,
marker="o",
label="Exact Probability of the Binomial Distribution",
)
plt.semilogy(thresholds, chernoff, marker="s", label="Chernoff bound")
plt.title("Upper probability of lot defect quantity")
plt.xlabel("Alarm threshold (defects per 1,000 units)")
plt.ylabel("Excess Probability and Upper Bound (log scale)")
plt.grid(alpha=0.3, which="both")
plt.legend()
plt.tight_layout()
plt.show()
| alarm_threshold_number_of_defects | How many times higher than expectations? | Exact Probability of the Binomial Distribution | Chernoff bound | |
|---|---|---|---|---|
| 0 | 25 | 1.25 | 1.545154e-01 | 0.560689 |
| 1 | 30 | 1.50 | 2.069652e-02 | 0.114870 |
| 2 | 35 | 1.75 | 1.326559e-03 | 0.010188 |
| 3 | 40 | 2.00 | 4.339876e-05 | 0.000441 |
| 4 | 45 | 2.25 | 7.717810e-07 | 0.000010 |

Reading the results
The farther the alarm threshold moves from the 20 expected defects, the exponential decrease in exact probability and Chernoff upper bound. Although the upper bound is larger than the exact probability, it can quickly evaluate the minimal probability digits. However, it is necessary to assume that defects in each individual are independent and have a certain probability. In processes where defects occur frequently due to equipment abnormalities, the binomial model itself tends to be underestimated, so overdispersion and intra-lot correlations are examined.
No.078: Hoeffding’s Inequality
Practical meaning
The 0/1 data for good or defective products always falls within . Using the Hoeffding inequality, the probability that the sample defect rate deviates by a certain amount from the true defect rate can be linked to the sample size without using the shape of the population distribution or population variance.
Definitions and calculations
About independent ,
If the right-hand side is set to an allowable risk of or less, you can design a distribution-independent sample size of .
Check with Python
hf_rng = np.random.default_rng(SEED + 78)
p, eps, reps = 0.03, 0.02, 80_000
n_values = np.array([500, 1_000, 2_000, 5_000, 10_000])
empirical = []
for n in n_values:
phat = hf_rng.binomial(n, p, reps) / n
# Include equality despite floating-point rounding at the boundary.
error = np.abs(phat - p)
empirical.append(
np.mean((error >= eps) | np.isclose(error, eps, rtol=0, atol=1e-12))
)
hoeffding = np.minimum(1, 2 * np.exp(-2 * n_values * eps**2))
hf_table = pd.DataFrame(
{
"number_of_inspections_n": n_values,
"Measurement error excess rate": empirical,
"Hoeffding bound": hoeffding,
}
)
display(hf_table)
plt.semilogy(
n_values,
np.maximum(empirical, 1 / reps),
marker="o",
label="Measurement error excess rate",
)
plt.semilogy(n_values, hoeffding, marker="s", label="Hoeffding bound")
plt.title("Probability of a Rate Error of at Least 2 Percentage Points")
plt.xlabel("number_of_inspections n")
plt.ylabel("Probability and upper bound (log scale)")
plt.grid(alpha=0.3, which="both")
plt.legend()
plt.tight_layout()
plt.show()
alpha = 0.05
n_required = int(np.ceil(np.log(2 / alpha) / (2 * eps**2)))
print(
f"error±{eps:.1%}to95%Guaranteed by the aboveHoeffdingSample size: {n_required:,}units"
)
| number_of_inspections_n | Measurement error excess rate | Hoeffding bound | |
|---|---|---|---|
| 0 | 500 | 0.012462 | 1.000000 |
| 1 | 1000 | 0.000375 | 0.898658 |
| 2 | 2000 | 0.000000 | 0.403793 |
| 3 | 5000 | 0.000000 | 0.036631 |
| 4 | 10000 | 0.000000 | 0.000671 |

error±2.0%to95%Guaranteed by the aboveHoeffdingSample size: 4,612units
Reading the results
Along with the sample size, both the measured error rate and the upper bound decrease. Hoeffding sample size does not use the true defect rate, so it can be designed at process startup, but it is conservative for low-defect processes. If there is autocorrelation in continuous production, nonrandom selection of inspection targets, or measurement errors, even if the sample size is formally met, the guarantee assumption is compromised.
On the log axis, zero observed frequency is displayed at . That plotting position is neither a true probability nor a bound.
No.079: Concentration Inequality
Practical meaning
The concentration inequality is a general term for the group of inequalities that guarantee how much the sample mean, etc., is concentrated around the expected value. Even with the same quality data, depending on how reliable the average, variance, and value range is, use different methods such as Chebyshev, Hoeffding, Bernstein, and others.
Definitions and calculations
Define the two-sided Bernstein-type upper bound for the mean of independent Bernoulli variables
Using variance information can make Bernstein’s bound tighter than Hoeffding’s. Chebyshev’s inequality itself does not require independence or boundedness. However, using as the variance of the mean in this comparison assumes independent Bernoulli trials.
Check with Python
p, n = 0.03, 2_000
eps_values = np.array([0.005, 0.010, 0.015, 0.020, 0.025])
ci_rng = np.random.default_rng(SEED + 79)
phat = ci_rng.binomial(n, p, 200_000) / n
error = np.abs(phat - p)
emp = np.array(
[
np.mean((error >= e) | np.isclose(error, e, rtol=0, atol=1e-12))
for e in eps_values
]
)
cheb = np.minimum(1, p * (1 - p) / (n * eps_values**2))
hoeff = np.minimum(1, 2 * np.exp(-2 * n * eps_values**2))
bern = np.minimum(
1, 2 * np.exp(-n * eps_values**2 / (2 * p * (1 - p) + 2 * eps_values / 3))
)
concentration = pd.DataFrame(
{
"allowable_error_eps": eps_values,
"Measured probability": emp,
"Chebyshev": cheb,
"Hoeffding": hoeff,
"Bernstein": bern,
}
)
display(concentration)
for col, marker in [
("Measured probability", "o"),
("Chebyshev", "s"),
("Hoeffding", "^"),
("Bernstein", "D"),
]:
plt.semilogy(
eps_values, np.maximum(concentration[col], 1e-6), marker=marker, label=col
)
plt.title(
"Comparison of Concentration Bounds"
)
plt.xlabel("Tolerance of defect rate ε")
plt.ylabel("Probability of Error Excess and Upper Bound (log scale)")
plt.grid(alpha=0.3, which="both")
plt.legend()
plt.tight_layout()
plt.show()
| allowable_error_eps | Measured probability | Chebyshev | Hoeffding | Bernstein | |
|---|---|---|---|---|---|
| 0 | 0.005 | 0.212185 | 0.582000 | 1.000000 | 8.874345e-01 |
| 1 | 0.010 | 0.010410 | 0.145500 | 1.000000 | 9.162047e-02 |
| 2 | 0.015 | 0.000160 | 0.064667 | 0.813139 | 2.725528e-03 |
| 3 | 0.020 | 0.000000 | 0.036375 | 0.403793 | 2.780068e-05 |
| 4 | 0.025 | 0.000000 | 0.023280 | 0.164170 | 1.121754e-07 |

Reading the results
In this simulation, all bounds exceed the empirical tail frequency. Chebyshev uses mean and variance, Hoeffding uses boundedness and independence, and Bernstein additionally uses variance information. All three calculations here assume the same independent Bernoulli model. Choose a bound whose assumptions are justified, and distinguish bounds, simulation frequencies, and model probabilities in reports.
On this log plot, values below , including zero, are displayed at . The table gives the actual values.
No.080: Asymptotic Normality
Practical meaning
Many estimates approach a normal distribution around true values as the sample size increases. By confirming this property of the maximum likelihood estimator of the defect rate , we can understand the basis and limitations for using normal approximation for confidence intervals and inter-plant comparisons of large samples.
Definitions and calculations
The maximum likelihood estimate for the Bernoulli sample is ,
Therefore, approximates . However, with low defect rates and small samples, zero defects occur frequently, and symmetrical Wald intervals may become inappropriate.
Check with Python
an_rng = np.random.default_rng(SEED + 80)
p, reps = 0.03, 50_000
rows = []
fig, axes = plt.subplots(1, 3, figsize=(13, 3.8))
for ax, n in zip(axes, [50, 500, 5_000]):
phat = an_rng.binomial(n, p, reps) / n
z = np.sqrt(n) * (phat - p) / np.sqrt(p * (1 - p))
se_hat = np.sqrt(phat * (1 - phat) / n)
lower, upper = phat - 1.96 * se_hat, phat + 1.96 * se_hat
coverage = np.mean((lower <= p) & (p <= upper))
rows.append([n, np.mean(phat == 0), z.mean(), z.std(ddof=1), coverage])
ax.hist(z, bins=45, density=True, alpha=0.65)
xs = np.linspace(-4, 4, 300)
ax.plot(xs, norm.pdf(xs), color="tab:red")
ax.set_title(f"Standardized defect rate (n={n})")
ax.set_xlabel("Standardized estimation error")
ax.set_ylabel("density")
ax.grid(alpha=0.3)
plt.tight_layout()
plt.show()
asymptotic_table = pd.DataFrame(
rows,
columns=[
"number_of_inspections_n",
"bad0Transaction rate",
"Mean of Normalization Error",
"of normalization errorSD",
"Wald95%Interval coverage rate",
],
)
display(asymptotic_table.round(4))

| number_of_inspections_n | bad0Transaction rate | Mean of Normalization Error | of normalization errorSD | Wald95%Interval coverage rate | |
|---|---|---|---|---|---|
| 0 | 50 | 0.2181 | -0.0040 | 0.9973 | 0.7812 |
| 1 | 500 | 0.0000 | 0.0046 | 1.0025 | 0.9233 |
| 2 | 5000 | 0.0000 | 0.0037 | 0.9973 | 0.9462 |
Reading the results
At , many samples contain no defects. Their estimated standard error is zero, and the Wald intervals have poor coverage. As sample size increases, the standardized error approaches a normal distribution and coverage approaches 95%. For low rates and small samples, compare Wilson or exact intervals and check the expected count .
Using the results in practice
From No.071 to No.080, the following four layers are required to determine manufacturing KPIs.
- Check Stability: Not only expecting the law of large numbers, but also visualizing cumulative means, stratification, and changes
- Quantifying estimation errors: Using the central limit theorem, Slutsky, and delta methods, convert point estimation into standard error and decision KPI width.
- Separating Guarantees from Forecasts: The upper bound of the concentration inequality is not a true probability. The fewer assumptions, the more conservative it may be.
- Checking finite samples: Before using asymptotic theory, examine skewness, tail, low incidence rate, autocorrelation, and effective sample size.
The sample size is determined not by “large or small” but by tolerance of error, misjudgment cost, and whether it is sufficient for the process structure.
Preparing for practical use
1. Fix the observation unit and denominator
Whether an individual, lot, day, or equipment is counted as one observation, the denominator of the defect rate, handling of re-inspected items, and the identification of missing or measurement errors are recorded in the data dictionary.
2. Examine the Assumption of Independence and Identical Distributions
We check time series plots and autocorrelations, stratification by equipment, products, materials, and shifts, as well as process change history. If consecutive lots are correlated, evaluate effective sample sizes and block units.
3. Agree on allowable margins and misjudgment costs
False alarms for process stoppages, missed abnormalities, additional inspections, and delivery delays are converted into amounts and labor to determine the required confidence level and sample size.
4. Operate separately by upper bound, approximate, and actual performance
The report displays the theoretical boundary, model-based estimated probabilities, and past performance excess rates separately, while retaining the assumptions used, target periods, and recalculation conditions. Even after implementation, coverage rates and alarm frequency are monitored and thresholds are updated.
Conclusion
- The law of large numbers supports the stability of cumulative means, but does not guarantee process variation or dependency
- By the central limit theorem, even skewed individual observations can be normally approximated to the mean of large samples
- Slutsky’s theorem and delta method support the replacement of unknown standard deviations and the evaluation of errors after KPI transformations
- Chebyshev, Markov, Chernoff, Hoeffding, and others suppress probability from above under different assumptions
- The values of the concentration inequality are not predictive probabilities but guarantee bounds, and conservatism also becomes a cost
- Asymptotic normality is useful, but for low defect rates and small samples, methods for finite samples are chosen
The limit theorem is not a slogan of “as long as there’s more data, it’s fine.” Only by clearly stating what assumptions, what errors to tolerate, and which decisions to adhere to will it become a tool for quality assurance and production management.
Consultations for Corporations
At Surikobo, we support everything from organizing data definitions in manufacturing to organizing data definitions, statistical models, simulations, in-house training using Python notebooks, and operational design for quality control, production KPIs, sampling inspections, process capabilities, and anomaly detection.
You can consult from stages such as “explaining the basis for the number of inspections,” “showing the margin of error in average KPIs at management meetings,” or “statistically redesigning existing control limits and alarm thresholds.”
📩 Contact Us: www.surikobo.co.jp/contact
Please feel free to consult us first.