I'm attempting an assignment in which we're supposed to write a function to simulate a geometric distribution with $p=0.03$. While plotting a histograms for about $100000$ simulations of the function, I got these:
The code is as follows:
import numpy as np import pandas as pd from random import random def simulateGeo(p=0.03): n = 1 while(random() >= p): n += 1 return n simresults = np.zeros(100000) for i in range(100000): simresults[i] = simulateGeo() pd.Series(simresults).hist(bins=200)
I'm just curious - what's the reason for these (seemingly regularly-spaced) gaps / spikes?