Area under a PDF curve
이전 댓글 표시
Hi all!
I have a brief question. I am trying to obtain the area under a PDF curve. Concretely, the PDF follows a Lognormal distribution with paremeter mu=0 and sigma=0.9.
zmax=10;
gridz=600;
m=0;
sig=0.9;
z=logspace(0,log(zmax)/log(10),gridz);
g=lognpdf(z,m,sig);
trapz(z,g)
However, the value I obtain is equal to 0.49, far from 1. Any advise please?
Thanks in advanced,
Ibai
댓글 수: 5
Torsten
2022년 3월 1일
z consists of 600 times the same value, namely 1...
Ibai Ostolozaga Falcon
2022년 3월 2일
The first element in the z-vector is z(1)=1.
To get trapz(z,g)=1, you will have to start with z(1) = small value > 0.
So
z = linspace(1e-8,10,gridz)
instead of
z=logspace(0,log(zmax)/log(10),gridz)
should work.
Ibai Ostolozaga Falcon
2022년 3월 3일
답변 (1개)
For pdf that matlab supports, you can use cdf function to find the area under pdf. For your case
zmax=10;
m=0;
sig=0.9;
logncdf(zmax, m, sig)
카테고리
도움말 센터 및 File Exchange에서 Mathematics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!