Skip to content

Instantly share code, notes, and snippets.

@jobliz
Created January 8, 2013 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jobliz/4488576 to your computer and use it in GitHub Desktop.
Save jobliz/4488576 to your computer and use it in GitHub Desktop.
heights = ["high", "medium", "short"]
dist = [0.2, 0.6, 0.2]
generator = position_generator(dist)
n = 10000
count = 0
high = 0
med = 0
low = 0
for x in xrange(n):
simulation = heights[generator.next()]
count += 1
if simulation == 'high':
high += 1
elif simulation == 'medium':
med += 1
elif simulation == 'short':
low += 1
print "Alta", "\t", high * 1.0 / count
print "Media", "\t", med * 1.0 / count
print "Baja", "\t", low * 1.0 / count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment