jeudi 17 juin 2021

problem in costructing gaussian random distribution in a range in Python

enter image description here

from random import seed
from random import random
from random import gauss
import matplotlib.pyplot as plt
NUM = []
seed(1)
for i in range(10000):

    num = min(10, max(0, gauss(4, 2)))
    NUM.append(num)

plt.hist(NUM, bins = 100) 
plt.show()

But, as shown in picture, there are lots of samples at "0" how to reduce that ?




Aucun commentaire:

Enregistrer un commentaire