- #1

Firben

- 145

- 0

## Homework Statement

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.

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

## 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 widthThen 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**