Last active
August 5, 2019 00:32
-
-
Save fynntimes/2df3a29737504063413fe2426c71d346 to your computer and use it in GitHub Desktop.
A general AP Statistics probability simulation script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Faizaan Datoo Pd3 | |
# A very simple example of using technology to automate simulations :) | |
# I /could/ have made it more complicated, but that would defeat the point! | |
import random | |
print "Enter a range of digits." | |
# Get those numbers... | |
minVal = input("\tYour minimum value: ") | |
maxVal = input("\tYour maximum value: ") | |
repetitions = input("\tAmount of repetitions: ") | |
perRepetition = input("\tAmount of random numbers per repetition: ") | |
ignoreRepeats = raw_input("\tIgnore repeats? (y/n): ") | |
print "Okay, crunching some numbers..." | |
tries = [] | |
for i in range(repetitions): | |
print "=== Repetition #" + str(i + 1) + " ===" | |
history = [] | |
for j in range(perRepetition): | |
# Generate random values, print them out | |
generated = random.randrange(minVal, maxVal) | |
# Check for duplicates if we have to! | |
if ignoreRepeats == "y": | |
while (generated in history): | |
generated = random.randrange(minVal, maxVal) | |
history.append(generated) | |
print str(generated) + " ", | |
print "Done. Enjoy!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment