Setup. A muon has rest energy m c² = 105.658 MeV and a proper mean lifetime τ = 2.197 µs, so cτ = 658.6 m. For total energy E the Lorentz factor is γ = E/(m c²) and the speed is β = √(1 - 1/γ²).
Earth frame: time dilation. The muon's clock runs slow by γ, so its mean lab-frame lifetime is γτ and its mean decay length is βγ c τ. Survival over a height H is P = exp(-H / (βγ c τ)). Without relativity (γ = 1) it would be exp(-H / (β c τ)), which for 15 km is about e-22.8: essentially no muons.
Muon frame: length contraction. The atmosphere is moving past the muon at βc and is squashed to H/γ. Ground arrives after a proper time H/(γ β c), and survival is exp(-t'/τ) with that time, giving exactly the same number. Both views describe one pair of events (creation, ground arrival) with the same invariant interval (c Δt)² - (Δx)² = (c Δτ)², computed in the checks by an explicit Lorentz transformation.
Monte Carlo. Each muon draws a proper decay time t' = -τ ln(u) and reaches the ground if t' > H/(γ β c). Fractions from batches of N muons have a binomial uncertainty √(P(1-P)/N), shown in the checks as a z-score.
Simplifications. A straight vertical path at constant energy: no energy loss in air (a real muon loses roughly 2 GeV crossing the atmosphere), no scattering, no inclination (real muons arrive at all zenith angles, lengthening the path), and a single production height (real muons form over a range of altitudes, mostly 10 to 20 km). The pictured number of muons is a sample, not a flux. Quoted sea-level figures (mean energy near 4 GeV, roughly one muon per square centimetre per minute) are typical textbook values.