A common way of displaying the distribution of a random variable is by a histogram. Consider the interval [a,b) divided into M sub-intervals (bins) of length ΔX. Given a set of N random values of x, call Nj the number of values that fall within the jth interval.
If the expected value of Nj is
<Nj> = N Int(from a+(j-1)Δx to a+jΔx) Px(x) dx ~ NΔx/2[Px(a+(j-1)Δx) + Px(a+jΔx)]
where ΔX = (b-a)/M
where Px(x) is the distribution for x
The Attempt at a Solution
If i want to write a line of code that is the number of particles in a histogram bin of width Δv.
Then what is the Px in Matlab code ? What is it equal to ? If i put Px equal to a arbitrary number say rand(N) then is the line below then correct ?
Nj = (N.*deltaX)./2*rand(1,N); % Number of particles in a histogram of width Δv