如何在Matlab中生成遵循偏态正态分布的随机数 [英] how to generate random numbers that follow skew normal distribution in matlab

查看:1342
本文介绍了如何在Matlab中生成遵循偏态正态分布的随机数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have probability density function of skew normal distribution.I want to generate random number that follow the skew normal distribution in matlab.

推荐答案

不能保证其性能/性能,但

Can't vouch for their performance/adequacy, but http://azzalini.stat.unipd.it/SN/ says the following, and has a link to a .zip file of MATLAB functions:

该库已由Nicola Sartori移植到Matlab.到目前为止,这指的是更新0.21.因此,不包括偏斜t分布的设施.但是,可以通过一组Matlab来获得歪斜t分布的部分功能.函数,由恩里克·巴蒂兹(Enrique Batiz)编写并提供(Enrique.Batiz [at] postgrad.mbs.ac.uk)

The library has been ported to Matlab by Nicola Sartori. So far, this refers to update 0.21; hence facilities for the skew-t distribution are not included. A portion of the facilities for the skew-t distribution is however available via a set of Matlab functions which have been written and made available by Enrique Batiz (Enrique.Batiz [at] postgrad.mbs.ac.uk)

另请参见此代码基本,但应易于携带.相关摘录如下.它使用RandNorm(也在链接的网页中),它是单位正态分布中的一对数字,在MATLAB中,您应该可以使用randn(2,1).

Also see this code which is in visual Basic, but should be easily portable. Relevant excerpt shown below. This uses RandNorm (also in the linked webpage) which is a pair of numbers from a unit normal distribution, and in MATLAB you should be able to use 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
    ' http://azzalini.stat.unipd.it/SN/faq.html

    ' 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

这篇关于如何在Matlab中生成遵循偏态正态分布的随机数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆