mardi 17 mars 2020

How can I generate n random values from a bimodal distribution in Python?

I tried generating and combining two unimodal distributions but think there's something wrong in my code.

N=400
mu, sigma = 100, 5
mu2, sigma2 = 10, 40
X1 = np.random.normal(mu, sigma, N)
X2 = np.random.normal(mu2, sigma2, N)
w = np.random.normal(0.5, 1, N)
X = w*X1 + (1-w)*X2
X = X.reshape(-1,2)

When I plot X I don't get a bimodal distribution




Aucun commentaire:

Enregistrer un commentaire