5.6b Mean-value and high-D labs
Source: Lab ideas from Computational Physics (Landau, Páez, Bordeianu), §5.6. Rewritten as original drills. Continues 5.6 Mean-value theorem and high-D Monte Carlo.
Practice the mean-value rule in 1D, then the 10D integral . Use the chapter LCG only.
Fixed LCG
r ← (1103515245 * r + 12345) % 2**31, uniform r / 2**31. Advance before each draw.
Formula refresh
Warm up: pick the matching equation among lookalikes (same walk as the theory lesson).
Labs
Activity: Mean-value 1D
Approximate with chapter-LCG samples (seed ). Print with 10 decimals.
Input: N.
Write-ups
Using “mean”, “width”, and “average”, explain:
State the 1D mean-value Monte Carlo formula for ∫_a^b f.
Minimum 3 words. Your answer must include: “mean”, “width”, “average”.
0 words
Meet the writing requirements, then you can open the model answer.
Explorers
# mean_value_nd.py — 10D mean-value sketch (original)
M = 2**31
def ten_d(N, seed):
r, acc = seed, 0.0
for _ in range(N):
s = 0.0
for _k in range(10):
r = (1103515245 * r + 12345) % M
s += r / M
acc += s * s
return acc / N