**1. The problem statement, all variables and given/known data**

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

**Given a set of N random values of x, call N**

**ΔX.**_{j}the number of values that fall within the jth interval.

**2. Relevant equations**

If the expected value of N

_{j}is

<N

_{j}> = N Int(from a+(j-1)

**Δx to a+j**

**Δx) P**_{x}(x) dx ~ N**Δx/2[P**_{x}(a+(j-1)**Δx) +****P**_{x}(a+j**Δx)]**

wherewhere

**ΔX = (b-a)/M**where P

_{x}(x) is the distribution for x

**3. 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 P

Nj = (N.*deltaX)./2*rand(1,N); % Number of particles in a histogram of width

Then what is the P

_{x}in Matlab code ? What is it equal to ? If i put P_{x}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**