Usage¶
partypy
can be used to simulate guest attendance at a party based on a list of guests, each assigned a “probability of attendance”. Below is a simple example of partypy
’s core functionality:
import partypy as pp
First, we’ll load in some example data:
df = pp.load_party()
df.head()
name | probability_of_attendance | |
---|---|---|
0 | Donovan Willis | 0.7 |
1 | Jocelyn Navarro | 0.7 |
2 | Houston Stein | 0.9 |
3 | Carlos Mullins | 0.5 |
4 | Bridger Pruitt | 0.7 |
Next, we’ll run 500 simulations of a party with this invited guest list:
results = pp.simulate_party(df["probability_of_attendance"],
n_simulations=500)
results.head()
Total guests | |
---|---|
Simulation | |
1 | 65 |
2 | 68 |
3 | 67 |
4 | 68 |
5 | 63 |
Finally, we can plot the results and optionally add a confidence interval of level C
:
pp.plot_simulation(results, C=0.95)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/tmp/ipykernel_424/2179226834.py in <module>
----> 1 pp.plot_simulation(results, C=0.95)
TypeError: plot_simulation() got an unexpected keyword argument 'C'