How to decide when a key input is uncertain: describe it by a distribution estimated from data, play the decision thousands of times with NumPy, and judge each plan on the whole distribution of its outcome. The newsvendor model, reading risk, the number of runs, a competitive bid, and a Streamlit app that puts the simulation in the manager’s hands.
Slides¶
Present full screen Download the PDF
Click or tap the slide to move forward, its left edge to go back; the arrow keys work too.
Reading¶
Monte Carlo Simulation simulates Qahwa House’s Ramadan gift-box season at the Olaya branch: it estimates demand from the errors of nine seasons of forecasts, shows why the best order is below the forecast and not 20% above it, checks the rule on the real seasons since 2018, reads the risk of each plan, and then chooses a bid for a catering contract with a limit on the chance of a loss.
Lab 14: Simulation app¶
In December 2025, each branch orders its Ramadan gift boxes once, for the whole season. How many should the Corniche branch order, and what risk comes with that order? You simulate 10,000 seasons, find the best order by simulation and by the critical ratio, compare the risks of three plans, choose a bid for a university’s coffee kiosks, then write a Streamlit app in which the manager picks a branch and an order and sees the distribution of profit.
Open the lab, then use its Open in Colab button.
Data: qahwa
_giftbox _demand .csv (40 rows: 4 branches over the nine seasons from 2016 to 2025, plus the 2026 forecasts). The notebook downloads it by itself. Submit the notebook and your
giftbox_app.pybefore the next lab session. The solutions are for checking your work afterwards.
Running the app¶
Colab cannot display a Streamlit page, so the lab tests the app with Streamlit’s AppTest. To see it in a browser:
GitHub Codespaces (free with GitHub Education) or your own computer: open a terminal in the folder with the app, run
pip install streamlit pandas scipy, thenstreamlit run giftbox_app.py. A browser tab opens athttp://localhost:8501.Share it: push the app and a
requirements.txtto a GitHub repository and deploy it on Streamlit Community Cloud, choosing the repository and the file. You get a public link.
The finished course version, with the prices as inputs, the standard error, every order on the same seasons, all four branches against the ordering habit, and a second tab for the catering bid: app.py and its requirements.txt. In a clone of the course repository, run it with streamlit run week14/app/app.py.
Next week¶
Multi-criteria decisions with AHP and TOPSIS, responsible analytics and AI, and the capstone demos.
→ Week 15: Multi-Criteria Decisions and Responsible Analytics