Domain: Physics — High-energy particle physics

Problem:
A high-energy cosmic-ray primary of energy \\(E_{\rm primary} = 10^{16}\,\mathrm{eV}\\) enters Earth's atmosphere at an altitude of 30 km. The primary produces a stochastic number of pions, which in turn decay into muons. The number of pions per shower follows a Poisson distribution with mean 10, and each pion produces a Poisson-distributed number of muons with mean 2. Only a fraction of the muons survive to reach the ground, with a survival probability of 0.5.  Simulate 100 such showers using the above parameters and estimate the mean number of muons per shower. Return the answer as a positive integer. Use numpy.random.default_rng(20250930) to ensure reproducibility.

Answer: 9

Solution code:
import numpy as np

rng = np.random.default_rng(20250930)
n_showers = 100
muons_per_shower = []

for shower in range(n_showers):
    n_pions = rng.poisson(10)
    total_muons = rng.poisson(n_pions * 2)
    surviving_muons = rng.binomial(total_muons, 0.5)
    muons_per_shower.append(surviving_muons)

mean_muons = np.mean(muons_per_shower)
result = int(np.round(mean_muons))
print(result)