NumPy Simulation Project
Use a shared simulated input to compare two calculation rules. Keep the model assumptions and experiment seed visible rather than presenting a random result as a forecast.
Your brief
This project generates bounded fictional collection amounts and applies two deterministic storage caps. The second cap is larger, so captured water should never be smaller for the same simulated input. Using the same draws isolates the rule difference instead of adding avoidable sampling noise. The model is intentionally simple and does not represent a real roof, climate, storage loss or engineering recommendation.
Run the code
Select Try in playground to preload the complete code into the NumPy editor. Nothing executes on import; choose Run when ready. The first execution loads the local Pyodide runtime and NumPy package. Each ordinary run starts fresh, with no access to this page’s cookies or personal files. In-memory streams and temporary virtual files belong to the runtime, not your PC.
For local work, use a separate virtual environment and run python simulation-project.py. Download the complete source. The reviewed local environment uses Python 3.12.14 and NumPy 2.5.4; the browser uses Pyodide 0.27.7 with NumPy 2.0.2. Compatible examples are checked in both. See the environment setup. No Apache or database server is required.
Worked solution
Show the worked solution
import numpy as np
draws = np.random.default_rng(41).uniform(0., 40., size=200)
small = np.minimum(draws, 20.)
large = np.minimum(draws, 30.)
print(bool((large >= small).all()))
print(bool((small <= 20.).all() and (large <= 30.).all()))
print(draws.shape)
Expected result
True True (200,)
The invariant compares plans on identical inputs and confirms their respective caps. A meaningful applied comparison would require justified distributions, units, costs and uncertainty reporting; this fixture teaches experimental structure only.
Extend and test
Change both caps to the same value and verify equal results. Then test a negative proposed cap by adding an explicit parameter rejection before calculation.
Use NumPy’s official reference for precise contracts, supported versions and numerical limitations.