Mathematical Foundations

IV.15 · Probability

Why can a running average settle while each observation stays random?

Follow one replayable sequence of observations and its actual prefix means. Separate a long-run convergence statement from the temporary rises and falls of one finite path.

Follow a seeded sample mean

Original Bernoulli population · PMF masses
Original Bernoulli population · PMF massesIdeal bernoulli population. Mean 0.25, variance 0.1875. The pseudo-random experiment approximates this mathematical sampling model.10: approximately 0.751: approximately 0.2501

One observation X · probability mass at 0 or 1

Actual prefix means · dashed line is the population target
Actual prefix means · dashed line is the population targetSeed 42, 200 actual observations: sample mean approximately 0.23, target 0.25, signed deviation approximately -0.02. 88 steps moved farther from the target. One path illustrates variability; it cannot prove a limit theorem. The theoretical iid mean standard deviation is σ/√m ≈ 0.0306186; it is not a guaranteed realized error.0.5751100200

Observation count m · vertical coordinate is the observed prefix mean, not a probability

First 16 actual observations of 200 (the path uses every observation):

  1. 0
  2. 1
  3. 0
  4. 1
  5. 0
  6. 1
  7. 0
  8. 1
  9. 0
  10. 0
  11. 0
  12. 0
  13. 0
  14. 0
  15. 0
  16. 1
Checkpoints from the same path · observed values are approximate
mSample meanSigned deviation
10-0.25
20.50.25
50.40.15
100.40.15
500.260.01
1000.280.03
2000.23-0.02

Seed 42, 200 actual observations: sample mean approximately 0.23, target 0.25, signed deviation approximately -0.02. 88 steps moved farther from the target. One path illustrates variability; it cannot prove a limit theorem. The theoretical iid mean standard deviation is σ/√m ≈ 0.0306186; it is not a guaranteed realized error.

True population mean
0.25
True population variance
0.1875
Observed sample mean
0.23
Observed signed deviation
−0.02
Theoretical iid mean standard deviation
0.030619
Unbiased sample variance estimate
0.17799

= exact model quantity · ≈ numerical companion or observed estimate

from 0 to 100, up to 2 decimal places

from 0 to 4294967295, whole numbers only

from 1 to 4000, whole numbers only

Seed 42, 200 actual observations: sample mean approximately 0.23, target 0.25, signed deviation approximately -0.02. 88 steps moved farther from the target. One path illustrates variability; it cannot prove a limit theorem.
μ=0.25,X‾m=1m∑i=1mXi≈0.23\mu=0.25,\quad\overline X_m=\frac1m\sum_{i=1}^mX_i\approx 0.23
Var⁡(X‾m)=σ2/mfor iid observations\operatorname{Var}(\overline X_m)=\sigma^2/m\quad\text{for iid observations}
X‾m→Pμas m→∞\overline X_m\xrightarrow{P}\mu\quad\text{as }m\to\infty

Read the first observations

Prefix m=5: actual sum ≈ 2, mean ≈ 0.4, signed deviation ≈ 0.15. First observations: 0, 1, 0, 1, 0.

X‾5=∑i=15Xi5≈0.4\overline X_{5}=\frac{\sum_{i=1}^{5}X_i}{5}\approx 0.4

Replay a seed, inspect actual observations, and follow their prefix means beside the theoretical population mean. Increase trials without expecting every new point to get closer.

Predict whether the next observation can move an already-close mean farther away. Then switch between Bernoulli, uniform, and exponential sources: what should the target line represent?

Intuition: a sum grows, but each new contribution gets diluted

A new observation enters the mean with weight 1/m1/m at step mm. Early observations can move it dramatically; later ones usually have less influence. Random fluctuations continue, but averaging independent information can make their collective effect smaller.

This is a statement about averages. Individual observations do not converge to the population mean: a fair Bernoulli draw remains either 00 or 11 even after a million earlier draws. The running mean is a distinct variable built from the complete prefix.

Definition

For independent identically distributed observations X1,X2,…X_1,X_2,\ldots with E[∣X1∣]<∞\mathbb E[|X_1|]<\infty, write μ=E[X1]\mu=\mathbb E[X_1] and

Xˉm=1m∑j=1mXj.\bar X_m=\frac1m\sum_{j=1}^mX_j.

The strong Law of Large Numbers states that Xˉm→μ\bar X_m\to\mu almost surely. In words, convergence holds on an event of probability one in the ideal infinite iid experiment. It does not require each finite error to decrease or give a deterministic sample size that makes every possible path accurate.

A weaker convergence-in-probability statement is enough for many applications: for every fixed ε>0\varepsilon>0, P(∣Xˉm−μ∣>ε)→0\mathbb P(|\bar X_m-\mu|>\varepsilon)\to0. The finite-variance argument below shows this weak statement under a stronger moment assumption.

Mechanics: actual observations, explicit seed

The explorer’s Bernoulli source has success probability pp, entered as a percent. Its mean and variance are pp and p(1−p)p(1-p) when pp is expressed as a probability. Uniform draws on [0,1)[0,1) have mean 1/21/2 and variance 1/121/12. Exponential rate-11 draws have mean and variance 11 and are visibly skewed rather than Gaussian.

The canonical run uses Bernoulli probability 1/41/4 (25 percent), seed 4242, and 200200 trials. Set a uint32 seed and a trial count from 11 to 40004000. Replay regenerates the same observations; every prefix mean comes from those observations. Reset restores the canonical source, seed, and count. The short and large presets use 1010 and 20002000 trials; the maximum uses 40004000. The trace inspects finite prefixes rather than replacing them with idealized trajectories.

The explicit pseudo-random generator updates integer state by (1664525s+1013904223) mod 232(1664525s+1013904223)\bmod 2^{32} and divides by 2322^{32}. Bernoulli draws compare the result with pp; uniform draws use it directly; exponential draws apply −log⁡(1−u)-\log(1-u). A deterministic pseudo-random stream is a simulation device, not a mathematical proof of independence or a source of cryptographic randomness.

Derivation: shrinking variance of the mean

For finite variance σ2\sigma^2 and independent observations, the covariance terms vanish:

E[Xˉm]=μ,Var⁡(Xˉm)=1m2∑j=1mVar⁡(Xj)=σ2m.\mathbb E[\bar X_m]=\mu,\qquad \operatorname{Var}(\bar X_m) =\frac1{m^2}\sum_{j=1}^m\operatorname{Var}(X_j) =\frac{\sigma^2}{m}.

Thus the standard deviation of a repeated-sample mean is σ/m\sigma/\sqrt m. Chebyshev’s inequality gives

P(∣Xˉm−μ∣≥ε)≤σ2mε2.\mathbb P(|\bar X_m-\mu|\geq\varepsilon) \leq\frac{\sigma^2}{m\varepsilon^2}.

This bound tends to zero for fixed positive ε\varepsilon, establishing convergence in probability in this finite-variance case. It is a probability bound over repetitions; it does not prohibit a particular run from exceeding a chosen error or prove the stronger almost-sure statement by itself.

Worked examples

For the hand sequence [1,0,1,1][1,0,1,1], prefix sums are 1,1,2,31,1,2,3 and means are

1,12,23,34.1,\quad\frac12,\quad\frac23,\quad\frac34.

Against a fair Bernoulli mean 1/21/2, the absolute errors are 1/2,0,1/6,1/41/2,0,1/6,1/4. The last two errors increase. That finite behavior is fully compatible with the LLN.

Worked example: Follow a seeded sample mean

Original Bernoulli population · PMF masses
Original Bernoulli population · PMF massesIdeal bernoulli population. Mean 0.25, variance 0.1875. The pseudo-random experiment approximates this mathematical sampling model.10: approximately 0.751: approximately 0.2501

One observation X · probability mass at 0 or 1

Actual prefix means · dashed line is the population target
Actual prefix means · dashed line is the population targetSeed 42, 200 actual observations: sample mean approximately 0.23, target 0.25, signed deviation approximately -0.02. 88 steps moved farther from the target. One path illustrates variability; it cannot prove a limit theorem. The theoretical iid mean standard deviation is σ/√m ≈ 0.0306186; it is not a guaranteed realized error.0.5751100200

Observation count m · vertical coordinate is the observed prefix mean, not a probability

First 16 actual observations of 200 (the path uses every observation):

  1. 0
  2. 1
  3. 0
  4. 1
  5. 0
  6. 1
  7. 0
  8. 1
  9. 0
  10. 0
  11. 0
  12. 0
  13. 0
  14. 0
  15. 0
  16. 1
Checkpoints from the same path · observed values are approximate
mSample meanSigned deviation
10-0.25
20.50.25
50.40.15
100.40.15
500.260.01
1000.280.03
2000.23-0.02

Seed 42, 200 actual observations: sample mean approximately 0.23, target 0.25, signed deviation approximately -0.02. 88 steps moved farther from the target. One path illustrates variability; it cannot prove a limit theorem. The theoretical iid mean standard deviation is σ/√m ≈ 0.0306186; it is not a guaranteed realized error.

True population mean
0.25
True population variance
0.1875
Observed sample mean
0.23
Observed signed deviation
−0.02
Theoretical iid mean standard deviation
0.030619
Unbiased sample variance estimate
0.17799

= exact model quantity · ≈ numerical companion or observed estimate

from 0 to 100, up to 2 decimal places

from 0 to 4294967295, whole numbers only

from 1 to 4000, whole numbers only

Seed 42, 200 actual observations: sample mean approximately 0.23, target 0.25, signed deviation approximately -0.02. 88 steps moved farther from the target. One path illustrates variability; it cannot prove a limit theorem.
μ=0.25,X‾m=1m∑i=1mXi≈0.23\mu=0.25,\quad\overline X_m=\frac1m\sum_{i=1}^mX_i\approx 0.23
Var⁡(X‾m)=σ2/mfor iid observations\operatorname{Var}(\overline X_m)=\sigma^2/m\quad\text{for iid observations}
X‾m→Pμas m→∞\overline X_m\xrightarrow{P}\mu\quad\text{as }m\to\infty

Read the first observations

Prefix m=5: actual sum ≈ 2, mean ≈ 0.4, signed deviation ≈ 0.15. First observations: 0, 1, 0, 1, 0.

X‾5=∑i=15Xi5≈0.4\overline X_{5}=\frac{\sum_{i=1}^{5}X_i}{5}\approx 0.4

Follow actual seeded prefix sums and means. Compare their deviations with the target line, while keeping σ/√m labeled as a theoretical repeated-mean scale.

For Bernoulli probability 1/41/4, population variance is 3/163/16. At m=100m=100, the mean variance is 3/16003/1600 and its standard deviation is 3/40≈0.0433012701892\sqrt3/40\approx0.0433012701892. Four times as many independent observations halve this standard deviation. They do not guarantee half the realized error in a particular path.

With seed 4242 and Bernoulli probability 1/21/2, the first three LCG-generated observations are [1,1,0][1,1,0], giving means [1,1,2/3][1,1,2/3]. This is a replay check, separate from the hand sequence above.

Executable reference code

The standard-library program explicitly implements the seed transition, stores observations, and calculates actual running sums. Assertions check literal generator states, first observations, replay, deterministic Bernoulli boundaries, trial bounds, and a nonmonotone hand path.

The NumPy version exposes the same stream and uses cumsum divided by prefix lengths. Neither program asserts that a final simulated error must be small: favorable-run acceptance would confuse a statistical theorem with a selected outcome.

code/python/probability_lln.py
"""Seeded observations and actual prefix means; a finite path is not a proof."""
from math import log1p, sqrt


def uniforms(seed):
    if type(seed) is not int or not 0 <= seed <= 0xffffffff:
        raise ValueError("Seed must be a uint32 integer")
    state=seed
    while True:
        state=(1664525*state+1013904223)&0xffffffff
        yield state/4294967296


def population(source, p=50):
    if source not in ('bernoulli','uniform','exponential'):
        raise ValueError("Unknown population")
    if isinstance(p,bool) or not isinstance(p,(int,float)) or not 0 <= p <= 100 or abs(p*100-round(p*100))>1e-8:
        raise ValueError("Probability percent must be in [0,100] with at most two decimals")
    q=p/100
    mean,variance={'bernoulli':(q,q*(1-q)),'uniform':(.5,1/12),'exponential':(1.,1.)}[source]
    draw=lambda u: float(u<q) if source=='bernoulli' else u if source=='uniform' else -log1p(-u)
    return mean,variance,draw


def experiment(source='bernoulli', p=25, seed=42, trials=200):
    if type(trials) is not int or not 1<=trials<=4000:
        raise ValueError("Trials must be an integer in [1,4000]")
    mean,variance,draw=population(source,p)
    rng=uniforms(seed)
    observations=[]
    means=[]
    scales=[]
    total=0.
    for m in range(1,trials+1):
        value=draw(next(rng))
        observations.append(value)
        total+=value
        means.append(total/m)
        scales.append(sqrt(variance/m))
    return observations,means,scales,mean,variance


def main():
    rng=uniforms(42)
    assert [next(rng)*4294967296 for _ in range(3)] == [1083814273,378494188,2479403867]
    result=experiment(p=50,trials=3)
    assert result[0]==[1.,1.,0.] and result[1]==[1.,1.,2/3]
    assert result == experiment(p=50,trials=3)
    assert experiment(p=0,trials=4)[1]==[0.]*4
    assert experiment(p=100,trials=4)[1]==[1.]*4
    values=[1,0,1,1]
    prefix=[sum(values[:m])/m for m in range(1,5)]
    assert prefix==[1,.5,2/3,.75]
    assert abs(prefix[2]-.5)>abs(prefix[1]-.5)  # LLN does not promise monotone error.
    for source in ('bernoulli','uniform','exponential'):
        observations,means,scales,mean,variance=experiment(source,trials=4000)
        assert len(observations)==len(means)==len(scales)==4000
        assert abs(means[-1]-sum(observations)/4000)<1e-14
        assert abs(scales[-1]**2-variance/4000)<1e-14
    for kwargs in ({'trials':0},{'trials':4001},{'seed':-1},{'source':'cauchy'},{'p':100.01}):
        try:
            experiment(**kwargs)
        except ValueError:
            pass
        else:
            raise AssertionError("Invalid experiment accepted")
    print("First observations and means:",result[:2])
    print("σ/√m is a theoretical repeated-mean scale, not a guaranteed error bound.")
    print("The iid finite-mean LLN is an asymptotic theorem; an LCG run illustrates it.")


if __name__=='__main__':
    main()
code/python/probability_lln_numpy.py
"""Vectorized prefix sums with the book's explicit uint32 seed contract."""
import numpy as np
from math import log1p, sqrt


def uniforms(seed):
    if type(seed) is not int or not 0 <= seed <= 0xffffffff:
        raise ValueError("Seed must be a uint32 integer")
    state=seed
    while True:
        state=(1664525*state+1013904223)&0xffffffff
        yield state/4294967296


def population(source, p=50):
    if source not in ('bernoulli','uniform','exponential'):
        raise ValueError("Unknown population")
    if isinstance(p,bool) or not isinstance(p,(int,float)) or not 0 <= p <= 100 or abs(p*100-round(p*100))>1e-8:
        raise ValueError("Probability percent must be in [0,100] with at most two decimals")
    q=p/100
    mean,variance={'bernoulli':(q,q*(1-q)),'uniform':(.5,1/12),'exponential':(1.,1.)}[source]
    draw=lambda u: float(u<q) if source=='bernoulli' else u if source=='uniform' else -log1p(-u)
    return mean,variance,draw


def experiment(source='bernoulli',p=25,seed=42,trials=200):
    if type(trials) is not int or not 1<=trials<=4000:
        raise ValueError("Trials must be an integer in [1,4000]")
    mean,variance,_=population(source,p)
    u=np.fromiter(uniforms(seed),dtype=float,count=trials)
    x=(u<p/100).astype(float) if source=='bernoulli' else u if source=='uniform' else -np.log1p(-u)
    m=np.arange(1,trials+1)
    return x,np.cumsum(x)/m,np.sqrt(variance/m),mean,variance


def main():
    x,means,scales,mu,variance=experiment(p=50,trials=3)
    np.testing.assert_array_equal(x,[1,1,0])
    np.testing.assert_allclose(means,[1,1,2/3],rtol=0,atol=1e-14)
    np.testing.assert_array_equal(experiment(p=50,trials=3)[0],x)
    for p in (0,100):
        np.testing.assert_array_equal(experiment(p=p,trials=4)[1],np.full(4,p/100))
    for source in ('bernoulli','uniform','exponential'):
        x,means,scales,mu,variance=experiment(source,trials=4000)
        np.testing.assert_allclose(means[-1],x.mean(),rtol=0,atol=1e-13)
        np.testing.assert_allclose(scales[-1]**2,variance/4000,rtol=0,atol=1e-14)
    path=np.cumsum([1,0,1,1])/np.arange(1,5)
    assert abs(path[2]-.5)>abs(path[1]-.5)
    for kwargs in ({'trials':0},{'seed':2**32},{'source':'invalid'},{'p':float('nan')}):
        try:
            experiment(**kwargs)
        except ValueError:
            pass
        else:
            raise AssertionError("Invalid experiment accepted")
    print("Actual prefix means ≈",means[:6])
    print("cumsum exposes the path; no favorable-run selection or monotone-error guarantee.")
    print("A Cauchy source lacks the finite expectation required by this LLN version.")


if __name__=='__main__':
    main()

Explore

Hold the seed and population fixed while increasing trials. Compare shared prefixes and explain why replay must preserve them. Find a step where absolute error increases, and identify the observation that moved the average away from the target.

Switch to the skewed exponential population and compare its observations with its mean path. Change the seed to observe a different path with the same theoretical target. At Bernoulli probabilities 00 or 11, explain why every observation and prefix mean is deterministic and the theoretical mean spread is zero.

Common mistakes and counterexamples

The law does not promise monotone improvement, exact equality at a finite step, or predictable compensation after a streak. A fair coin that has produced many successes still has success probability 1/21/2 on its next independent trial. The average can adjust without the coin remembering past imbalance.

If all observations repeat one common random variable YY, then Xˉm=Y\bar X_m=Y at every mm: there is no variance reduction. Common marginals alone do not supply independence. An iid Cauchy source gives a different warning: it lacks a finite absolute first moment and has no finite population mean to which this LLN version can assert convergence.

Numerical considerations

The simulation is bounded and uses the exact integer seed transition. Uniform uu lies in [0,1)[0,1), so the exponential transform never asks for log⁡(0)\log(0). The code uses log1p to evaluate log⁡(1−u)\log(1-u) accurately near zero. Floating observations and running means are numerical approximations, even when the model’s moments have exact rational forms.

Finite simulation length, pseudo-random generator quality, floating accumulation, and sampling variability are separate limitations. A plotted σ/m\sigma/\sqrt m scale describes theoretical spread under iid assumptions. It is neither a confidence interval nor a guarantee that the observed error lies inside it; interpreting coverage requires an additional probability statement.

Engineering and ML connections

A Monte Carlo estimate averages model-generated quantities. Its target is an expectation, and independent finite-variance samples give a standard-deviation scale proportional to 1/m1/\sqrt m. Reaching half the scale typically requires four times the work; reducing variance can be as valuable as drawing more samples.

Training batches, simulation draws, and measured data can be dependent. Before using iid averaging intuition, inspect how examples are sampled and whether the intended expectation exists. More correlated observations need not provide the same information as more independent ones.

Exercises

Compute exact prefix means and theoretical variances. Keep those model quantities separate from one observed path’s error.

calculation

Compute a real prefix path

Observed Bernoulli values are [1,0,1,1]. Give the means of the first 1, 2, 3, and 4 observations.

calculation

Distinguish population spread from mean spread

Independent Uniform[0,1) observations have μ = 1/2 and variance 1/12. For their mean over m = 100 draws, give its expectation and variance.

calculation

Calculate a theoretical error scale

Bernoulli success probability is 1/4. Give population variance and the squared theoretical scale (σ/√m)² for m = 100 independent observations.

explanation

Does every new sample get closer?

For [1,0,1,1] with true Bernoulli mean 1/2, the prefix mean is exactly 1/2 at m=2 and 2/3 at m=3. Does this contradict the LLN?

Choose one answer

explanation

Check the mean exists

Which statement correctly limits the iid LLN discussed here?

Choose one answer

Summary and checkpoints

The iid finite-mean LLN concerns long-run averages. Check that you can construct a prefix path, identify nonmonotone deviations, derive finite-variance mean spread σ/m\sigma/\sqrt m, explain dependence and Cauchy warnings, and distinguish seeded illustration from theorem proof.

The map of the book

97 of 97 chapters written · eight Parts

demo Foundation demo Try the live vector example Open as a page

Part I

Mathematical Language

The notation and mental objects everything else uses.

9 of 9 chapters written

  1. I.1 Scalars, quantities, units, powers and roots available
  2. I.2 Coordinates and points available
  3. I.3 Vectors: components, magnitude, and direction reference chapter available
  4. I.4 Algebraic expressions, equations and inequalities available
  5. I.5 Functions as input → transformation → output available
  6. I.6 Essential function families available
  7. I.7 Sets, intervals, and relations available
  8. I.8 Indexed quantities and summation available
  9. I.9 The notation map for ML available

Part II

Linear Algebra

Matrices as transformations: the strongest foundation in the book.

19 of 19 chapters written

  1. II.1 Vector addition and subtraction available
  2. II.2 Scalar multiplication and vector scaling available
  3. II.3 Norms, magnitude, and normalization available
  4. II.4 Dot product, angle, and orthogonality available
  5. II.5 Projection and distance to a direction available
  6. II.6 Linear combinations and span available
  7. II.7 Linear independence, basis, and coordinates available
  8. II.8 Matrices as linear transformations available
  9. II.9 Matrix × vector available
  10. II.10 Matrix × matrix as composition available
  11. II.11 Transpose and orthogonality available
  12. II.12 Determinant: orientation and area/volume scaling available
  13. II.13 Linear systems as intersecting constraints available
  14. II.14 Gaussian elimination and row operations available
  15. II.15 Rank and invertibility available
  16. II.16 Inverse matrices available
  17. II.17 Eigenvalues and eigenvectors available
  18. II.18 Orthogonal bases and least-squares geometry available
  19. II.19 Singular Value Decomposition available

Part III

Calculus

Change, local approximation, and sensitivity made visible.

15 of 15 chapters written

  1. III.1 Limits through approach available
  2. III.2 Continuity and local behavior available
  3. III.3 Derivative as secant → tangent available
  4. III.4 Derivative as rate of change and local linear model available
  5. III.5 Derivative rules available
  6. III.6 Chain rule available
  7. III.7 Multivariable functions and partial derivatives available
  8. III.8 Gradient and directional derivatives available
  9. III.9 Jacobian available
  10. III.10 Computational graphs and automatic differentiation available
  11. III.11 Hessian and curvature available
  12. III.12 Integrals as accumulation available
  13. III.13 Fundamental derivative/integral connection available
  14. III.14 Numerical differentiation available
  15. III.15 Numerical integration available

Part IV

Probability

Uncertainty through sample spaces, evidence, and repetition.

16 of 16 chapters written

  1. IV.1 Random experiments, outcomes, and sample spaces available
  2. IV.2 Events and probability mass available
  3. IV.3 Counting and finite probability where needed available
  4. IV.4 Conditional probability as restricted sample space available
  5. IV.5 Independence available
  6. IV.6 Bayes' theorem as probability-mass update available
  7. IV.7 Random variables available
  8. IV.8 PMF, PDF, and CDF available
  9. IV.9 Bernoulli and Binomial distributions available
  10. IV.10 Uniform and Gaussian distributions available
  11. IV.11 Expectation available
  12. IV.12 Variance and standard deviation available
  13. IV.13 Joint, marginal, and conditional distributions available
  14. IV.14 Covariance and correlation available
  15. IV.15 Law of Large Numbers available
  16. IV.16 Central Limit Theorem available

Part V

Statistics

From observed data to estimates, intervals, and likelihood.

10 of 10 chapters written

  1. V.1 Data summaries: mean, median, mode available
  2. V.2 Spread: variance, standard deviation, robust interpretation available
  3. V.3 Population, sample, and sampling variability available
  4. V.4 Estimators and estimation available
  5. V.5 Confidence intervals through repeated sampling available
  6. V.6 Covariance matrices and multivariate spread available
  7. V.7 Regression fundamentals available
  8. V.8 Likelihood available
  9. V.9 Maximum Likelihood Estimation available
  10. V.10 Maximum A Posteriori estimation available

Part VI

Optimization

Learning as repeated parameter updates governed by an objective.

10 of 10 chapters written

  1. VI.1 Objective functions and optimization landscapes available
  2. VI.2 Local vs global optima and stationary points available
  3. VI.3 Convexity available
  4. VI.4 Gradient descent flagship chapter available
  5. VI.5 Learning rate and convergence behavior available
  6. VI.6 Momentum available
  7. VI.7 Stochastic and mini-batch gradient descent available
  8. VI.8 Adam intuition available
  9. VI.9 Constraints and projected/penalized intuition available
  10. VI.10 Numerical stopping and optimization diagnostics available

Part VII

Information Theory

Logarithms, entropy, and the loss behind token prediction.

8 of 8 chapters written

  1. VII.1 Logarithms and log probabilities in computation available
  2. VII.2 Self-information available
  3. VII.3 Entropy available
  4. VII.4 Cross entropy and negative log-likelihood available
  5. VII.5 KL divergence available
  6. VII.6 Logits and softmax available
  7. VII.7 Numerical stability: log-sum-exp and stable softmax available
  8. VII.8 From token logits to language-model loss available

Part VIII

Numerical Computing

Why equivalent expressions behave differently on real machines.

10 of 10 chapters written

  1. VIII.1 Floating-point representation available
  2. VIII.2 Rounding and representation error available
  3. VIII.3 Error propagation and conditioning available
  4. VIII.4 Catastrophic cancellation available
  5. VIII.5 Overflow and underflow available
  6. VIII.6 Stable algorithms available
  7. VIII.7 Numerical linear algebra realities available
  8. VIII.8 Sparse matrices and sparse structure available
  9. VIII.9 Vectorized computation available
  10. VIII.10 Reproducibility, random seeds, and nondeterminism available