Here's the cowboy method of brute simulation (probably my favorite way of exploring problems). I don't think I did this on the extra credit because of my easier shower idea (plus it was EC and the homeworks were kind of large).
Anyways, I was super curious to see if empirically the answer seemed to be distributed around a 1.75 value, or the 1.565 value.
First, generating n random values:
In [3]:
from random import randint
def gen_rand_nums(n):
for i in range(n):
yield randint(1,100)
Then to run trials (trying to keep this simple and dumb to catch bugs---I find generating random things often tricky):
In [5]:
def rand_trial(n):
if n <= 50:
return 1
if n <= 75:
return 2
if n <= 100:
return 3
Now for running the whole thing:
In [6]:
def run_trials(n):
product = 1
for i in gen_rand_nums(n):
product *= rand_trial(i)
return product ** (1 / n)
And some test runs/output:
In [12]:
print(run_trials(100))
print(run_trials(250))
print(run_trials(500))
print(run_trials(1000))
print(run_trials(1200))
print(run_trials(1300))
In [ ]: