Matlab: what is the distribution equal to in Matlab code

Firben

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 ΔX. Given a set of N random values of x, call Nj the number of values that fall within the jth interval.
2. Relevant equations
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

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 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

Related Engineering and Comp. Sci. Homework News on Phys.org

Greg Bernhardt

Thanks for the post! This is an automated courtesy bump. Sorry you aren't generating responses at the moment. Do you have any further information, come to any new conclusions or is it possible to reword the post?

"Matlab: what is the distribution equal to in Matlab code"

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving