News for hackers. Stuff that matters.
Re:How Fair Is My D20? (2015) by appleiigs on Tuesday February 26, 2019 @06:23PM (#19259369)
Python3

    import random, statistics

    num_of_sims = 10000
    num_of_rolls = 3000
    results = []

    for s in range(num_of_sims):

        sum_of_rolls = 0

        # roll 20 sided dice
        for r in range(num_of_rolls):
            sum_of_rolls += random.randint(1,20)

        # keep track of the average value
        results.append(sum_of_rolls / num_of_rolls)

    print("ave: ", statistics.mean(results)) # which is 10.49915
    print("stdev: ", statistics.stdev(results)) # which is 0.10492
Now where did I put my statistical tables?

There are no comments on this comment yet.