MATLAB |根据均值和概率区间计算 gamma dist 参数
我有一个包含 2 个未知数的 2 个方程组,我想使用 MATLAB 求解该方程组,但不知道具体如何编程。我已经获得了一些有关伽马分布的信息(平均值为 1.86,1.61 和 2.11 之间的 90% 间隔),最终想要获得平均值和方差。我知道我可以使用正态近似,但我宁愿求解 A 和 B、伽马分布的形状和尺度参数,并以这种方式找到均值和方差。在伪 MATLAB 代码中,我想解决这个问题:
gamcdf(2.11, A, B) - gamcdf(1.61, A, B) = 0.90;
A*B = 1.86;
你会如何解决这个问题?如果有帮助的话,我有符号数学工具箱。
I have a system of 2 equations in 2 unknowns that I want to solve using MATLAB but don't know exactly how to program. I've been given some information about a gamma distribution (mean of 1.86, 90% interval between 1.61 and 2.11) and ultimately want to get the mean and variance. I know that I could use the normal approximation but I'd rather solve for A and B, the shape and scale parameters of the gamma distribution, and find the mean and variance that way. In pseudo-MATLAB code I would want to solve this:
gamcdf(2.11, A, B) - gamcdf(1.61, A, B) = 0.90;
A*B = 1.86;
How would you go about solving this? I have the symbolic math toolbox if that helps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
平均值为 A*B。那么你能用平均值(mu)和 B 来求解 A 吗?
当然,除非你认识 B,否则这没有任何好处。是吗?
看你第一个表情。可以代替吗?
这会让你更亲近吗?也许。除了不完整的伽马函数本身之外,不会有任何有用的符号解决方案可用。如何在 matlab 中用数值方法求解一个未知数方程?使用 fzero。
当然,fzero 寻找零值。但减去 0.90,问题就解决了。
我们可以定义一个 fzero 可以使用的函数吗?使用函数句柄。
所以尝试一下吧。在我们这样做之前,我总是建议先策划一些事情。
唔。该图表明,可能很难找到函数的零点。如果您尝试一下,您会发现这里需要良好的 fzero 起始值。
对我的第一次尝试感到抱歉。更好的 fzero 起始值,加上更多的绘图确实给出了产生所需形状的伽玛分布。
事实上,这是一条非常“正常”的曲线,即高斯曲线。
The mean is A*B. So can you solve for perhaps A in terms of the mean(mu) and B?
Of course, this does no good unless you knew B. Or does it?
Look at your first expression. Can you substitute?
Does this get you any closer? Perhaps. There will be no useful symbolic solution available, except in terms of the incomplete gamma function itself. How do you solve a single equation numerically in one unknown in matlab? Use fzero.
Of course, fzero looks for a zero value. But by subtracting 0.90, that is resolved.
Can we define a function that fzero can use? Use a function handle.
So try it. Before we do that, I always recommend plotting things.
Hmm. That plot suggests that it might be difficult to find a zero of your function. If you do try it, you will find that good starting values for fzero are necessary here.
Sorry about my first try. Better starting values for fzero, plus some more plotting does give a gamma distribution that yields the desired shape.
In fact this is a very "normal", i.e, Gaussian, looking curve.