如何创建参数分布?

发布于 2024-11-19 13:38:12 字数 984 浏览 6 评论 0 原文

我正在尝试使用以下 PDF 创建倾斜正态分布

我正在使用以下命令(引用自 http://en.wikipedia.org/wiki/Skew_normal_distribution):

我正在尝试执行以下操作:

SkewedNormal := Distribution(PDF = unapply(2*phi(x, mu, sigma)*Phi(alpha*x, mu, sigma), x, mu, sigma, alpha))

该命令执行没有错误,与以下命令相同:

R := RandomVariable(SkewNormal)

但当我尝试执行以下操作时,问题就开始了:

CDF(R,x)

错误,(在统计中:-CDF)无效输入:q 使用第三个参数 sigma,该参数缺失

好的,我添加第三个参数:

CDF(R,x,y)

错误,(在统计中:-CDF)意外参数:y

如果您之前尝试通过以下方式初始化随机变量:

R := RandomVariable(SkewNormal(mu, sigma))

错误,(在统计:-Distribution 中)输入无效:IsKnownDistribution 期望其第一个参数 dn 为类型

name 类型,但收到 module () 导出条件,PDF,类型;期权分布,连续; end module

如何在 Maple 14 中创建参数分布?

I'm trying to create Skewed Normal distribution with the following PDF

I'm using the following command for that (referenced from http://en.wikipedia.org/wiki/Skew_normal_distribution):

I'm trying to do the following:

SkewedNormal := Distribution(PDF = unapply(2*phi(x, mu, sigma)*Phi(alpha*x, mu, sigma), x, mu, sigma, alpha))

This command executes without errors, the same as the following command:

R := RandomVariable(SkewNormal)

but the problems start when I try to do the following:

CDF(R,x)

Error, (in Statistics:-CDF) invalid input: q uses a 3rd argument, sigma, which is missing

Ok, I add the third parameter:

CDF(R,x,y)

Error, (in Statistics:-CDF) unexpected parameters: y

If you try previously to init random variable the following way:

R := RandomVariable(SkewNormal(mu, sigma))

Error, (in Statistics:-Distribution) invalid input: IsKnownDistribution expects its 1st argument, dn, to be of type

name, but received module () export Conditions, PDF, Type; option Distribution, Continuous; end module

How do you create parametric distribution in Maple 14?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

七颜 2024-11-26 13:38:12

不能只对x取消申请吗? (请注意,您在发布的代码中存在拼写错误,使用 SkewedNormal 与 SkewNormal。)

with(Statistics):

SkewNormal := Distribution(PDF =
     unapply(2*phi(x, mu, sigma)*Phi(alpha*x, mu, sigma), x));

R := RandomVariable(SkewNormal):

CDF(R,x);

最终结果是一个包含 alpha、mu 和 sigma 的表达式。因此,可以使用 subseval 来实例化参数的值。

Can you not unapply with respect to only x? (Note you had a typo in the posted code, using SkewedNormal vs SkewNormal.)

with(Statistics):

SkewNormal := Distribution(PDF =
     unapply(2*phi(x, mu, sigma)*Phi(alpha*x, mu, sigma), x));

R := RandomVariable(SkewNormal):

CDF(R,x);

The final result there is an expression containing alpha, mu, and sigma. So subs or eval could then be used to instantiate at values for the parameters.

笑梦风尘 2024-11-26 13:38:12

如果有人遇到同样的问题,这里是我设法以这种方式解决它的方法:

SkewedNormal := (xi, omega, alpha) ->
Distribution
(
    PDF = ((x) -> x*sqrt(2)*exp(-(1/2)*(x-xi)^2/omega^2)*(1/2+(1/2)*erf((1/2)*alpha*(x-xi)*sqrt(2)/omega))/(omega*sqrt(Pi))),
    CDF = (proc (x) local t; options operator, arrow; return 1/2+(1/2)*erf((1/2)*(x-xi)*sqrt(2)/omega)-(int(exp(-(1/2)*(t-xi)^2*(1+t^2)/omega^2)/(1+t^2), t = 0 .. alpha))/Pi end proc),
    Mean = xi+omega*alpha*sqrt(2/Pi)/sqrt(1+alpha^2),
    Variance = omega^2*(1-2*alpha^2/(sqrt(1+alpha^2)^2*Pi)),
    MGF = ((x) -> 2*exp(xi*x+(1/2)*omega^2*x^2)*(1/2+(1/2)*erf((1/2)*omega*alpha*x*sqrt(2)/sqrt(1+alpha^2))))
)

这种方式允许定义参数分布

示例:

X:=SkewedNormal(u,v,m); # Skewed normal distribution with xi=u, omega=v, alpha=m

Y:=SkewedNormal(a,b,c); # Skewed normal distribution with xi=a, omega=b, alpha=c

它还可以与Statistics包中的函数一起使用,例如RandomVariable:

Rx:=RandomVariable(X);    
Ry:=RandomVariable(Y);

并调用:

CDF(Ry,x);

给出

公式

In case anybody will face the same problem here's how I managed to solve it this way:

SkewedNormal := (xi, omega, alpha) ->
Distribution
(
    PDF = ((x) -> x*sqrt(2)*exp(-(1/2)*(x-xi)^2/omega^2)*(1/2+(1/2)*erf((1/2)*alpha*(x-xi)*sqrt(2)/omega))/(omega*sqrt(Pi))),
    CDF = (proc (x) local t; options operator, arrow; return 1/2+(1/2)*erf((1/2)*(x-xi)*sqrt(2)/omega)-(int(exp(-(1/2)*(t-xi)^2*(1+t^2)/omega^2)/(1+t^2), t = 0 .. alpha))/Pi end proc),
    Mean = xi+omega*alpha*sqrt(2/Pi)/sqrt(1+alpha^2),
    Variance = omega^2*(1-2*alpha^2/(sqrt(1+alpha^2)^2*Pi)),
    MGF = ((x) -> 2*exp(xi*x+(1/2)*omega^2*x^2)*(1/2+(1/2)*erf((1/2)*omega*alpha*x*sqrt(2)/sqrt(1+alpha^2))))
)

This way allows defining parametric distribution

Examples:

X:=SkewedNormal(u,v,m); # Skewed normal distribution with xi=u, omega=v, alpha=m

Y:=SkewedNormal(a,b,c); # Skewed normal distribution with xi=a, omega=b, alpha=c

It also works with functions from Statistics package, such as RandomVariable:

Rx:=RandomVariable(X);    
Ry:=RandomVariable(Y);

And calling:

CDF(Ry,x);

Gives

Formula

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