# normalizing a normal distribution

159 ビュー (過去 30 日間)
Maksym Zawrotny 2019 年 1 月 8 日
コメント済み: Jasmine Alvarez 2021 年 2 月 16 日
I just need to plot a gaussion distribution plot given mean (mu) and standard deviation (sigma). I used:
gauss1 = normpdf(x, mu, sigma)
But it's output its not normalized. I would like it to be normalized as probability density function. I need to plot it next to histogram normalized it by:
histogram(dataSerie, 'Normalization', 'probability')
After using normpdf it looked like: it is clear that integral from 0 to 1 is not equal 1, so it is not probability density function.

サインインしてコメントする。

### 採用された回答

OCDER 2019 年 1 月 8 日
The normpdf returns the PDF in terms of %. To normalize to fraction, divide the output of normpdf by 100.
If you compute PDF for longer spans of X, then the sum of the PDF approaches 1 (100%). See below.
Mu = 0.5;
Sig = 0.2;
X = Mu-10*Sig:0.01:Mu+10*Sig;
Y = normpdf(X, Mu, Sig);
sum(Y)
= 100 %in percentage
Yp = Y/100;
sum(Yp)
= 1 %in fraction
##### 2 件のコメント表示非表示 1 件の古いコメント
Jasmine Alvarez 2021 年 2 月 16 日
Two years later, but thank you so much! I was trying to figure out why my normpdf was summing to 16...my step size was one factor but I couldn't figure out the other.

サインインしてコメントする。

R2017b

### Community Treasure Hunt

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

Start Hunting!