Normalize histogram of normally distributed data
3 ビュー (過去 30 日間)
古いコメントを表示
How can I normalize a histogram of normally distributed points? I have tried using histnorm from the file exchange and a few other suggestions in the help forums, but the height of my bins are on the order of 10^4.
I am using normrand to distribute data points, but the height of the histogram (or height of the pdf when I use histfit) always depends upon the number of data points and the number of bins I use.
Thanks
0 件のコメント
回答 (2 件)
Honglei Chen
2013 年 3 月 12 日
You just need to normalize it toward the number of points
x = randn(1024,1)
[n,b] = hist(x)
bar(b,n/sum(n))
2 件のコメント
Honglei Chen
2013 年 3 月 13 日
編集済み: Honglei Chen
2013 年 3 月 14 日
Then what is your rule of normalization, normalize towards what?
Tom Lane
2013 年 3 月 14 日
I would normalize it to area 1. The usual histogram has area equal to binwidth*sum(n), so divide by that. Probably binwidth=b(2)-b(1).
6 件のコメント
Image Analyst
2013 年 6 月 27 日
We can't run this - it says span is undefined. The histogram is a quantized PDF. You won't get the true PDF unless you have an infinite number of infinitely thin histogram bins. So of course the histogram changes as you change the bin width - you have a finite number of samples that are counted. And you can't get infinitely thin, infinitely many bins with digitized, discrete data because that's just how a computer works.
Peter Perkins
2013 年 6 月 27 日
You want to compare a histogram to a PDF. Tom's suggestion is the correct one. The histogram integrates to binwidth*numObservations, the PDF to 1. The easiest thing to do is to scale your PDF by multiplying by binwidth*numObservations, but you can also call hist, get the bin counts, normalize them by dividing by binwidth*numObservations, and call bar.
If your PDF is a fit to the data, I'd recommend plotting the data and fitting the model using the dfittool GUI, which makes the plot your looking for (as well as many others) automatically.
Hope this helps.
参考
カテゴリ
Help Center および File Exchange で Histograms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!