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=26652)

poster 2019-12-14 20:38

如何在Matlab中生成遵循偏态正态分布的随机数
 
我有偏态正态分布的概率密度函数,我想在matlab中生成遵循偏态正态分布的随机数。



[B]回答:[/B]

无法保证其性能/性能,但[URL]http://azzalini.stat.unipd.it/SN/[/URL]表示以下内容,并且具有指向MATLAB函数的.zip文件的链接:
[INDENT]该库已由Nicola Sartori移植到Matlab。到目前为止,这是指更新0.21;因此不包括偏斜t分布的设施。但是,可以通过Enrique Batiz编写并提供的[URL="http://azzalini.stat.unipd.it/SN/skt-matlab.zip"]一组Matlab函数[/URL]来获得偏斜t分布的部分[URL="http://azzalini.stat.unipd.it/SN/skt-matlab.zip"]功能[/URL] (Enrique.Batiz [位于] postgrad.mbs.ac.uk)

[/INDENT]另请参见在Visual Basic中的[URL="http://www.ozgrid.com/forum/showthread.php?t=108175&page=1"]此代码[/URL] ,但应易于移植。相关摘录如下。这使用RandNorm(也在链接的网页中),它是单位正态分布中的一对数字,在MATLAB中,您应该能够使用randn(2,1) 。

Function RandSkew(fAlpha As Single, _ Optional fLocation As Single = 0, _ Optional fScale As Single = 1, _ Optional bVolatile As Boolean = False) As Single ' shg 2008-0919 ' [url]http://azzalini.stat.unipd.it/SN/faq.html[/url] ' Returns a random variable with skewed distribution ' fAlpha = skew ' fLocation = location ' fScale > 0 = scale Dim sigma As Single Dim afRN() As Single Dim u0 As Single Dim v As Single Dim u1 As Single If bVolatile Then Application.Volatile Randomize (Timer) sigma = fAlpha / Sqr(1 + fAlpha ^ 2) afRN = RandNorm() u0 = afRN(1) v = afRN(2) u1 = sigma * u0 + Sqr(1 - sigma ^ 2) * v RandSkew = IIf(u0 >= 0, u1, -u1) * fScale + fLocation End Function

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


所有时间均为北京时间。现在的时间是 23:19

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