A small simulation experiment, see slide 43 in the lecture slides.
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('seaborn-darkgrid')
np.random.seed(777)
We simulate a scenario where a student takes an exam. There are 5 question, and each question can award a score of up to 6 points. We assume that the score that the student gets for one question is a discrete uniform random value between 0 and 6. (That is, almost like a die roll, but with the option of getting no points at all.) The scores for the different questions are independent of each other, which is probably an unrealistic assumption. We return the total score.
n_questions = 5
max_score_question = 6
def exam_score():
scores = np.random.randint(0, max_score_question + 1, size=n_questions)
total_score = sum(scores)
return total_score
Simulate 1 exam and then 10000 exams.
exam_score()
samples = [exam_score() for _ in range(10000)]
samples[:10]
We plot the histogram of the exam scores. If your sample is large enough, the shape of the histogram will be fairly bell-shaped. (The theoretical explanation for this, which we will come back to later in the course, is that sums of independent random variables become more and more similar to the Normal (Gaussian) distribution, as the number of terms in the sum grows.)
plt.hist(samples, bins=100);