Created
April 25, 2022 15:32
-
-
Save audhiaprilliant/506891b8e83d1b00b471feb02dd5316d to your computer and use it in GitHub Desktop.
Simulation of Monty Hall Problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Perform a empirical simulation | |
| data_stick = monty_hall( | |
| num_iter = 1000, | |
| switch = False | |
| ) | |
| # Create a data rame | |
| df_stick = pd.DataFrame( | |
| data = data_stick | |
| ) | |
| # Create a column of probability | |
| df_stick['win_rate'] = (df_stick['win'] / df_stick['iter']).apply( | |
| lambda x: round(x, 3) | |
| ) | |
| df_stick['lose_rate'] = (1 - df_stick['win_rate']).apply( | |
| lambda x: round(x, 3) | |
| ) | |
| # Show data frame | |
| df_stick.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment