Thread Subject: Curve fitting to a histogram to give a probability density function.

Subject: Curve fitting to a histogram to give a probability density function.

From: Noel Kelleher

Date: 9 Jun, 2008 14:20:03

Message: 1 of 6

Hi All,

If you have a histogram of data that is normally
distributed, is there a matlab function that will fit a
curve to the bell shape of the histogram to give you a
general probability density function for that data set.

Thanks.

Subject: Curve fitting to a histogram to give a probability density function.

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 9 Jun, 2008 14:37:44

Message: 2 of 6

In article <g2je6j$m19$1@fred.mathworks.com>,
Noel Kelleher <naych@hotmail.com> wrote:

>If you have a histogram of data that is normally
>distributed, is there a matlab function that will fit a
>curve to the bell shape of the histogram to give you a
>general probability density function for that data set.

No, there isn't. If the histogram is normally distributed then it
has infinite tails in both direction. There are no routines in Matlab
that can work with infinite vectors.

If you want to pretend that the histogram counts have a normal
distribution even though they do not have infinite tails, then
simply take the mean() and standard deviation of the count data;
the pdf is then just the pdf of the normal distribution with those
mean and standard deviation.
--
  "What we have to do is to be forever curiously testing new
  opinions and courting new impressions." -- Walter Pater

Subject: Curve fitting to a histogram to give a probability density function.

From: Tom Lane

Date: 9 Jun, 2008 15:36:05

Message: 3 of 6

>>If you have a histogram of data that is normally
>>distributed, is there a matlab function that will fit a
>>curve to the bell shape of the histogram to give you a
>>general probability density function for that data set.
...
> If you want to pretend that the histogram counts have a normal
> distribution even though they do not have infinite tails, then
> simply take the mean() and standard deviation of the count data;
> the pdf is then just the pdf of the normal distribution with those
> mean and standard deviation.

Noel, whether or not you have the Statistics Toolbox available, you might
find it helpful to look at the following demo on this topic:

http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/cfitdfitdemo.html

I agree with Walter that you are usually better off fitting a distribution
to the raw data rather than fitting a curve to the histogram.

-- Tom

Subject: Curve fitting to a histogram to give a probability density function.

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 9 Jun, 2008 16:01:51

Message: 4 of 6

In article <g2jil5$j4u$1@fred.mathworks.com>,
Tom Lane <tlane@mathworks.com> wrote:

>I agree with Walter that you are usually better off fitting a distribution
>to the raw data rather than fitting a curve to the histogram.

I didn't say or hint that, but it sounds like a good idea to me!
--
  "And believe me, I was very lousy yesterday.
   I had nothing to say, and, by God, I said it."
                                          -- Walter Wellesley Smith

Subject: Curve fitting to a histogram to give a probability density function.

From: Noel Kelleher

Date: 9 Jun, 2008 16:04:02

Message: 5 of 6

"Tom Lane" <tlane@mathworks.com> wrote in message
<g2jil5$j4u$1@fred.mathworks.com>...
> >>If you have a histogram of data that is normally
> >>distributed, is there a matlab function that will fit a
> >>curve to the bell shape of the histogram to give you a
> >>general probability density function for that data set.
> ...
> > If you want to pretend that the histogram counts have a
normal
> > distribution even though they do not have infinite
tails, then
> > simply take the mean() and standard deviation of the
count data;
> > the pdf is then just the pdf of the normal distribution
with those
> > mean and standard deviation.
>
> Noel, whether or not you have the Statistics Toolbox
available, you might
> find it helpful to look at the following demo on this topic:
>
>
http://www.mathworks.com/products/statistics/demos.html?file=/products/demos/shipping/stats/cfitdfitdemo.html
>
> I agree with Walter that you are usually better off
fitting a distribution
> to the raw data rather than fitting a curve to the histogram.
>
> -- Tom
>
>

Ok, thanks guys!

Subject: Curve fitting to a histogram to give a probability density function.

From: Mastaneh

Date: 6 Aug, 2008 16:33:02

Message: 6 of 6

"Noel Kelleher" <naych@hotmail.com> wrote in message
<g2jk9i$ehq$1@fred.mathworks.com>...
> "Tom Lane" <tlane@mathworks.com> wrote in message
> <g2jil5$j4u$1@fred.mathworks.com>...
> > >>If you have a histogram of data that is normally
> > >>distributed, is there a matlab function that will fit
a
> > >>curve to the bell shape of the histogram to give you a
> > >>general probability density function for that data
set.
> > ...
> > > If you want to pretend that the histogram counts have
a
> normal
> > > distribution even though they do not have infinite
> tails, then
> > > simply take the mean() and standard deviation of the
> count data;
> > > the pdf is then just the pdf of the normal
distribution
> with those
> > > mean and standard deviation.
> >
> > Noel, whether or not you have the Statistics Toolbox
> available, you might
> > find it helpful to look at the following demo on this
topic:
> >
> >
> http://www.mathworks.com/products/statistics/demos.html?
file=/products/demos/shipping/stats/cfitdfitdemo.html
> >
> > I agree with Walter that you are usually better off
> fitting a distribution
> > to the raw data rather than fitting a curve to the
histogram.
> >
> > -- Tom
> >
> >
>
> Ok, thanks guys!

Hi Noel,
yes, it's possible and I've done that.
I think what you're trying to do is the "distribution
fitting" not the curve fitting; so you could in fact have a
look at
http://www.mathworks.com/products/statistics/demos.html?
file=/products/demos/shipping/stats/cdffitdemo.html

Once you plot the histogram of the original data, find the
frequency counts and bin locations, make a linespace
vector, and generate a pdf or cdf function using
the 'estimated' values from the data.
Hope it helps!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
probability den... Noel Kelleher 9 Jun, 2008 10:25:05
histogram Noel Kelleher 9 Jun, 2008 10:25:05
normal distribu... Noel Kelleher 9 Jun, 2008 10:25:05
rssFeed for this Thread

Contact us at files@mathworks.com