Trapz 给出否定结果:为什么?
我正在尝试对广义正态分布进行数值积分。我期望它下面的面积为 1。我得到的是 -1。为什么会这样呢?
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)
I am 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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该功能实际上是
So try
,它应该解决问题。
The function is actually
So try
and it should sort things out.
阅读 Trapz 的帮助文件...这就是
您需要的 一切写:
trapz(x,密度GG)
read the help file of Trapz... it's all there
you need to write:
trapz(x,densityGG)