Skip to content

Instantly share code, notes, and snippets.

@telliott99
Last active May 8, 2021 12:00
Show Gist options
  • Save telliott99/7a28b357e171a677f6d86c455c771799 to your computer and use it in GitHub Desktop.
Save telliott99/7a28b357e171a677f6d86c455c771799 to your computer and use it in GitHub Desktop.
from matplotlib import pyplot as plt
import random
N = 10000
n = 100
L = list()
tL = list()
v = 0
for i in range(N):
r = random.random()
v += r
if v >= 1.0:
v -= 1.0
L.append(int(n*r))
tL.append(int(n*v))
plt.hist(L,n,alpha=0.5,color='r')
plt.hist(tL,n,alpha=0.5,color='b')
plt.savefig('example.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment