Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
looking for a function to draw from an empirical distribution

Subject: looking for a function to draw from an empirical distribution

From: Luna Moon

Date: 14 Jan, 2011 02:30:50

Message: 1 of 3

from historical data that I collected,
i divide the data into 100 bins
and count the frequency for each bin,
and that's my empirical distribution,
is there a Matlab function that allows me to draw randomly from that
empirical distribution?
thanks

Subject: looking for a function to draw from an empirical distribution

From: Jos (10584)

Date: 14 Jan, 2011 09:02:07

Message: 2 of 3

Luna Moon <lunamoonmoon@gmail.com> wrote in message <cd707e7c-01a4-4649-af1e-0fd10371aa66@w29g2000vba.googlegroups.com>...
> from historical data that I collected,
> i divide the data into 100 bins
> and count the frequency for each bin,
> and that's my empirical distribution,
> is there a Matlab function that allows me to draw randomly from that
> empirical distribution?
> thanks

RANDP does exactly that

HD = [1 1 1 2 2 2 2 2 8 4 4 4 4 4 7 7] ; % historical data
unHD = unique(HD) % unique data (bins)
F = histc(HD,unHD) % frequency of each bin
rix = randp(F,10,1) % get 10 random indices according to the distribution
RD = unHD(rix) % get associated bin

RANDP can be found on the FEX:
http://www.mathworks.com/matlabcentral/fileexchange/8891

hth
Jos

Subject: looking for a function to draw from an empirical distribution

From: Peter Perkins

Date: 14 Jan, 2011 15:20:30

Message: 3 of 3

On 1/13/2011 9:30 PM, Luna Moon wrote:
> from historical data that I collected,
> i divide the data into 100 bins
> and count the frequency for each bin,
> and that's my empirical distribution,
> is there a Matlab function that allows me to draw randomly from that
> empirical distribution?

If you have access to the Statistics Toolbox, either MNRND or RANDSAMPLE
can be used for this.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us