So I want to know something, that seems simple but is mathematically stumping me in some code.
in the code block
import random
def randomGen(num):
# Just a base prototype
randVal = random.randrange(num)
return randVal % 10
outputCount = [0 for x in range(10)] # Hold the count in
for i in range(1000000):
myVal = str(randomGen(10))
# print("Value " + myVal, end = '\t')
outputCount[int(myVal)]+=1
print(outputCount)
outputCount = [0 for x in range(10)] # Hold the count in
for i in range(1000000):
myVal = str(randomGen(10000))
# print("Value " + myVal, end = '\t')
outputCount[int(myVal)]+=1
print(outputCount)
I understand that you are giving rand a much larger sample size, but does that actually increase the "randomness" of the value that you get from it, I ran the code a few times, not a million but a few, and statistically I feel as if it will always lead to roughly the same grouping. Like if you were to split a deck of cards in half, you'd attain roughly half the sum of the values on each side, if the deck had been shuffled in any order.
I'm unsure if this is just me being nitpicky, but I don't for some reason, want to place an extensive "seed" in the value for rand because it seems unneeded, or is it?
Aucun commentaire:
Enregistrer un commentaire