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:
Histogram to Probability ditribution function

Subject: Histogram to Probability ditribution function

From: Mehdi bahonar

Date: 13 Mar, 2010 08:47:05

Message: 1 of 4

Hi There,

Do you know how we can convert histogram plot to probability density function plot?

Thanks,
maryam

Subject: Histogram to Probability ditribution function

From: Sadik

Date: 13 Mar, 2010 11:03:06

Message: 2 of 4

a = randn(1,10000);
[n,x] = hist(a,50);
plot(x,n/10000/diff(x(1:2)))
hold on
plot(x,normpdf(x,0,1),'r')

Therefore, n/10000/diff(x(1:2)) is your pdf. [diff(x(1:2)) looks at deltaX, that is bin width.]

"Mehdi bahonar" <mehdiuoc@yahoo.com> wrote in message <hnfje9$r0d$1@fred.mathworks.com>...
> Hi There,
>
> Do you know how we can convert histogram plot to probability density function plot?
>
> Thanks,
> maryam

Subject: Histogram to Probability ditribution function

From: Wayne King

Date: 13 Mar, 2010 15:44:05

Message: 3 of 4

"Mehdi bahonar" <mehdiuoc@yahoo.com> wrote in message <hnfje9$r0d$1@fred.mathworks.com>...
> Hi There,
>
> Do you know how we can convert histogram plot to probability density function plot?
>
> Thanks,
> maryam

Hi maryam, if you have the Statistics Toolbox, histfit() will superimpose a probability density function for a number of distributions.
Wayne

Subject: Histogram to Probability ditribution function

From: the cyclist

Date: 13 Mar, 2010 20:43:05

Message: 4 of 4

"Mehdi bahonar" <mehdiuoc@yahoo.com> wrote in message <hnfje9$r0d$1@fred.mathworks.com>...
> Hi There,
>
> Do you know how we can convert histogram plot to probability density function plot?
>
> Thanks,
> maryam

As has been mentioned, use HISTFIT if you know the underlying distribution type that you want to fit (e.g. normal distribution). If you do not, then you need to do a non-parametric fit. You can use the KSDENSITY function to do this. Note that this is a bit of an art in addition to science. You might want to read up on "kernel density estimation".

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