gaussian histogram so that area is equal to one.
    13 ビュー (過去 30 日間)
  
       古いコメントを表示
    
I have a quick question. I am creating my data in the following manner:
a = -100; b = 100;
x = a + (b-a) * rand(1, 500);
m = (a + b)/2;
s = 30;
DATA = gauss(x, m, s);
where the function gauss is implemented as follows:
function f = gauss(x,mu,s)
p1 = -.5 * ((x - mu)/s) .^ 2;
p2 = (s * sqrt(2*pi));
f = exp(p1) ./ p2;
Now, the area under DATA is not equal to one. So I am doing something like this to make it equal to 1:
num_bins = length(DATA); 
stand_DATA = hist(DATA,num_bins) ./ sum(hist(DATA,num_bins));
Now the question is. The areaa under stand_DATA is equal to one now. But it does not make sense as num_bins = length(DATA). Isn't it in this case each bin essentially gets one and only one data point?
0 件のコメント
回答 (1 件)
  bym
      
 2013 年 4 月 23 日
        it does not make sense to me to have the number of bins equal to your length of data. The purpose of a histogram is to describe your data in terms of intervals...not each data point. Below I have binned your data into 10 intervals and normalized the results
n = hist(data,10)
n =
       4    21    53    88   135   122    52    17     6     2
sum(n/500)
ans =
       1
0 件のコメント
参考
カテゴリ
				Help Center および File Exchange で Numerical Integration and Differential Equations についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

