Truncated mean for truncated gaussian distribution
이전 댓글 표시
Hello,
Is there any way to write the function
G(x) = int_{-inf}^{x} z * pdf(z) dz
where pdf(z) is a normal distribution with mean mu and std sigma (perhaps some way involving erf or erfc)? Note that G(inf) = mu.
Thanks in advance.
Ita
답변 (1개)
Tom Lane
2012년 4월 27일
Consider using the Symbolic Toolbox, if you have it:
>> syms x z
>> pi = sym('pi');
>> zmean = int(x*exp(-x^2/2)/sqrt(2*pi),-Inf,z)/int(exp(-x^2/2)/sqrt(2*pi),-Inf,z)
zmean =
-2^(1/2)/(2*pi^(1/2)*exp(z^2/2)*(erf((2^(1/2)*z)/2)/2 + 1/2))
>> subs(zmean,1.5)
ans =
-0.1388
>> t = randn(1e6,1); mean(t(t<1.5))
ans =
-0.1376
>> t = randn(1e6,1); mean(t(t<1.5))
ans =
-0.1383
>> t = randn(1e6,1); mean(t(t<1.5))
ans =
-0.1399
카테고리
도움말 센터 및 File Exchange에서 Matrix Computations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!