# How to generate surface preserving probability density function from histogram

조회 수: 7 (최근 30일)
lvn 2015년 7월 18일
답변: Ghada Saleh 2015년 7월 20일
I have a histogram with non uniform bins. From this I would like to estimate a smooth probability density function(basically also a histogram but with much finer bins), so that when I integrate it over the different original bin edges, I recover my histogram exactly.
Does anyone know a way how to do this?
Thanks in advance!

댓글을 달려면 로그인하십시오.

### 답변 (1개)

Ghada Saleh 2015년 7월 20일
Hi Ivn,
I understand you want to fit a histogram to a probability density function. Your first step is to make the area of the histogram equal to one. This can be done using the following code and assuming your data is 'x':
[heights,locations] = hist(x);
width = locations(2)-locations(1);
heights = heights / (n*width);
Now if you plot 'heights' that should give you a rough estimate of the discrete probability density function. If you want to fit your histogram to a known probability distribution, you can use histfit directly.
I hope this helps,
Ghada

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by