The √n law (and one Newton step)
Worked examples
Read the claim, then run it and check the machine agrees. One at a time — nothing here is taken on trust.
import math
def norm_cdf(x: float) -> float:
return 0.5 * (1.0 + math.erf(x / math.sqrt(2.0)))
print("Phi(0) =", norm_cdf(0.0))
print("Phi(1.96) =", norm_cdf(1.96))
print("Phi(-1.96) =", norm_cdf(-1.96), " (= 1 - Phi(1.96): symmetry)")
Φ relates to the error function by Φ(x) = ½(1 + erf(x/√2)) — no lookup tables, no scipy. The two values worth carrying in your head: Φ(0) = 0.5 and Φ(1.96) ≈ 0.975002, which is why "±1.96 standard errors" is the 95% confidence interval stamped on every Monte Carlo price you'll ever quote.
import math, random
random.seed(7)
n, total = 0, 0
for target in (100, 10_000, 1_000_000):
while n < target:
total += random.choice([-1, 1])
n += 1
print(f"n = {n:>9,} running mean = {total/n:+.5f} theory SE = 1/sqrt(n) = {1/math.sqrt(n):.5f}")
A fair ±1 coin has mean 0 and σ = 1, so the sample mean's standard error is 1/√n. Watch the running mean hug its shrinking error bar: within ~0.02 of zero at a hundred flips, ~0.01 at ten thousand, ~0.001 at a million. Each extra decimal of accuracy cost 100× the flips — this is the compute bill of Module 8's Monte Carlo pricer, previewed with a coin.
x = 1.0 # solve x^2 = 2 from a lazy guess
for i in range(5):
x = x - (x * x - 2.0) / (2 * x) # one Newton step: x -= f(x)/f'(x)
print(f"step {i + 1}: x = {x:.15f} error = {abs(x - 2**0.5):.2e}")
Errors: 8.6e-02 → 2.5e-03 → 2.1e-06 → 1.6e-12 → 0. The exponent roughly doubles each step — quadratic convergence. Compare the bisection method's one-bit-per-step crawl. In the challenge you'll do the same thing in two dimensions, where f′ becomes the Jacobian matrix and the division becomes a 2×2 solve — exactly the shape of a production curve calibrator, minus a few thousand dimensions.
Check the concept
One question at a time. Unsure? Revisit the lecture, then answer.
The challenge
Pass the quiz to unlock the challenge — your code will still be waiting here.