MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   如何在MATLAB中实现此功能? (https://www.labfans.com/bbs/showthread.php?t=23865)

poster 2019-12-10 20:48

如何在MATLAB中实现此功能?
 
我正在使用具有我要使用的功能的书。但是我不认为我从函数中得到了正确的值。

这是书中的说明:

[IMG]https://i.stack.imgur.com/yCns1.png[/IMG]

这是我在MATLAB中创建的函数:

function [ shortProbability ] = pShort( zkt, zktStar, short) if zkt > zktStar shortProbability = 0; else normalizer = 1/(1-exp(-short*zktStar)); shortProbability = normalizer * (short * exp(-short*zkt)); end end 我插入的值是:

zkt = 0:1:100 zktStar = 50; short = 0.01; 但是,我的图的行为不像我应该以的形式结束,这是这样的:

[IMG]https://i.stack.imgur.com/G7z7M.png[/IMG]

我从图表中得到了这个,看起来很正确,但是我认为它没有被正确规范化:

[IMG]https://i.stack.imgur.com/vxIeO.png[/IMG]

谁能帮我纠正此功能?



[B]回答:[/B]

这就是[URL="http://en.wikipedia.org/wiki/Exponential_distribution"]指数分布[/URL] 。您可以从统计信息工具箱使用[URL="http://www.mathworks.com/help/toolbox/stats/exppdf.html"]EXPPDF[/URL]和[URL="http://www.mathworks.com/help/toolbox/stats/expcdf.html"]EXPCDF[/URL] :

normalizer = 1 ./ ( expcdf(zktStar,1/short) - expcdf(0,1/short) ); shortProbability = exppdf(zkt, 1/short) * normalizer; 它应该等同于您所拥有的...

这是我将其与您[URL="https://stackoverflow.com/questions/3644037/help-understanding-a-definitive-integral/3644076#3644076"]先前问题中[/URL]的图组合后得到的结果:

[IMG]https://i.stack.imgur.com/EP01w.png[/IMG]

为了确认,我们计算每条曲线下的面积(足够接近1 ):

>> trapz(zkt,hitProbabilty) ans = 1 >> trapz(zkt,shortProbability) ans = 1.0077

[url=https://stackoverflow.com/questions/3646231]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 01:05

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.