Skip to main content

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 I=∫[0,1]10(∑xi)2 d10x=155/6I=\int_{[0,1]^{10}}(\sum x_i)^{2}\,d^{10}x=155/6. 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 e−xe^{-x}

Approximate ∫01e−x dx\int_0^1 e^{-x}\,dx with NN chapter-LCG samples (seed 11). Print with 10 decimals.

Input: N.

Write-ups​

0/4 solved
5.6b.W1

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/ 3 min

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

Next: 5.7 Monte Carlo variance reduction.