I want to randomly select numbers with the probability acording to the sum of 2 normal/gaussian distributions and make a histogram.
basicaly
import numpy as np u, vth = 0,1 # mean and standard deviation v= np.random.normal(u, vth, 1000)+np.random.normal(-u, vth, 1000) v.histogram() However I get the error numpy.ndarray' object has no attribute 'histogram'. Another problem is that this isn't normalized so my results shouldn't be right...
21 Answer
I think what you are looking for is to make a histogram plot of a normal distribution. Have you tried using matplotlib library's histogram function? It can be done easily like so:
import numpy as np u, vth = 0,1 # mean and standard deviation v= np.random.normal(u, vth, 1000)+np.random.normal(-u, vth, 1000) import matplotlib.pyplot as plt plt.hist(v) 