Skip to content

Instantly share code, notes, and snippets.

View EvanTurner's full-sized avatar

Evan Turner EvanTurner

  • NoVA, USA
View GitHub Profile
@EvanTurner
EvanTurner / monte_carlo_hall.py
Created August 23, 2018 16:30
Python implementation of a Monte Carlo simulation of the famous "cars and goats" problem. Yes it is a mess.
# USAGE just copy/paste this in to a Python interpreter and invoke it with try_doors_with_strategy(), e.g.
# >>> num_trials, found_cars, found_goats = try_doors_with_strategy()
# >>> print 'car rate: {}'.format(str(1.0 * found_cars / num_trials))
# car rate: 0.338
# >>> num_trials, found_cars, found_goats = try_doors_with_strategy(num_trials = int(1e6), strategy='switch')
# >>> print 'car rate: {}'.format(str(1.0 * found_cars / num_trials))
# car rate: 0.666569
### Keybase proof
I hereby claim:
* I am EvanTurner on github.
* I am evanturner (https://keybase.io/evanturner) on keybase.
* I have a public key whose fingerprint is 35A0 06B4 A8C9 1A3E 80E2 A17D 928F 8CAF 9B48 347F
To claim this, I am signing this object:
curl http://a1.phobos.apple.com/us/r1000/000/Features/atv/AutumnResources/videos/entries.json | sed -n 's/.*url"\ :\ "\([^"]*\).*/\1/p' | xargs -n 1 curl -O -L