开发者

Trapz gives negative result: why?

I a开发者_开发技巧m trying to numerically integrate a Generalized Normal Distribution. I expect the area under it to be 1. What I get is -1. Why is it like this?

mu=0;
alpha=0.5;
beta=2;

x=-2:0.01:2;
densityGG = beta/(2*alpha*gamma(1/beta)) * exp(-power(abs(x-mu)/alpha,beta));

plot(x,densityGG);
trapz(densityGG,x)


The function is actually

trapz(X, Y)

So try

trapz(x, densityGG)

and it should sort things out.


read the help file of Trapz... it's all there

you need to write: trapz(x,densityGG)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜