Statistics: Ch 4 Probability and Statistics (71 of 74) Monte Carlo Simulation: Ex. 4

preview_player
Показать описание

To donate:

We will use the Monte Carlo simulation to find the number of times it would take to find the correct key to unlock a door. Given: 4 keys are placed in a box, only #1 key opens the door. A key is picked at random WITHOUT REPLACEMENT. Example 4

Next video in this series can be seen at:
Рекомендации по теме
Комментарии
Автор

In case anyone wants to try it for themselves I coded it below. If you don't know programming you can still run it. Just google _"python online ide"_ (repl is fine) and copy and paste what's below and click run:

import random

def monty_carlo(i, keys):
rand_tot = 0
for n in range(i):
rand_n = random.randint(1, keys)
rand_tot += rand_n
rand_average = rand_tot / (n+1)
return rand_average

def question():
keys = int(input("How many keys? "))
i = int(input("How many guesses? "))
rand_average = monty_carlo(i, keys)
print("The average was {} with {:, } guesses and {:, } keys".format(rand_average, i, keys))

while True:
again = input("Again? (y/n) ")
if again == "y" or again == "Y":
question()
elif again == "n" or again == "N":
break

question()

davidmurphy
Автор

What would the probability be if you replaced the key each time? I would think one of the solutions would never pick the right key, which would mess up the average probability

chriskeefe
Автор

How many combinations and repetitive. Structure by 7 swara of sangeet possible
7 sounds are sa rey ga ma pa dha nee sa
So found all the permutation and combined results of randomness of music with 7 knots ?

anilsharma-evmy