microsoft / microsoft/Data-Science-For-Beginners
Rt equation is inverted in the COVID spread notebook
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 37.2k
- Forks
- 7.5k
- PR merge metrics
- No merged PRs in 30d
Description
Description
In the Computing $R_t$ section of the COVID spread notebook, the displayed equation has the earlier four-day total in the numerator and the most recent four-day total in the denominator:
R_t = (I_{t-7} + I_{t-6} + I_{t-5} + I_{t-4})
/ (I_{t-3} + I_{t-2} + I_{t-1} + I_t)
This is inverted relative to the interpretation that values above 1 indicate growth.
The code immediately below the equation computes the ratio in the other direction:
df["Rt"] = df["ninfected"].rolling(8).apply(
lambda x: x[4:].sum() / x[:4].sum()
)
Within the chronological eight-day window, x[:4] is the earlier period and x[4:] is the recent period, so the implementation is consistent with:
R_t = (I_{t-3} + I_{t-2} + I_{t-1} + I_t)
/ (I_{t-7} + I_{t-6} + I_{t-5} + I_{t-4})
For example, if daily infections increase from 10 in each of the earlier four days to 20 in each of the recent four days, the displayed equation gives 0.5, while the code gives 2.
Suggested change
Swap the numerator and denominator in the Markdown equation so that it matches the code and the surrounding explanation.
File: 2-Working-With-Data/07-python/notebook-covidspread.ipynb
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open 2-Working-With-Data/07-python/notebook-covidspread.ipynb and find the Computing $R_t$ section. Compare the Markdown equation with the following rolling Python calculation, then swap the equation's numerator and denominator so it matches the code and the explanation that values above 1 indicate growth.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100