Trapz 给出否定结果:为什么?

发布于 2024-11-28 07:40:27 字数 328 浏览 5 评论 0原文

我正在尝试对广义正态分布进行数值积分。我期望它下面的面积为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天气好吗我好吗 2024-12-05 07:40:27

该功能实际上是

trapz(X, Y)

So try

trapz(x, densityGG)

,它应该解决问题。

The function is actually

trapz(X, Y)

So try

trapz(x, densityGG)

and it should sort things out.

伴我老 2024-12-05 07:40:27

阅读 Trapz 的帮助文件...这就是

您需要的 一切写:
trapz(x,密度GG)

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

you need to write:
trapz(x,densityGG)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文