Skip to content

Instantly share code, notes, and snippets.

@audhiaprilliant
Created April 25, 2022 15:32
Show Gist options
  • Select an option

  • Save audhiaprilliant/506891b8e83d1b00b471feb02dd5316d to your computer and use it in GitHub Desktop.

Select an option

Save audhiaprilliant/506891b8e83d1b00b471feb02dd5316d to your computer and use it in GitHub Desktop.
Simulation of Monty Hall Problem
# 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