gaussian histogram so that area is equal to one.

조회 수: 5 (최근 30일)
jenka
jenka 2013년 4월 23일
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?

답변 (1개)

bym
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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by