我想在 VBA 中使用 Weibull 和广义帕累托分布生成随机数。你能帮我解决一下吗。我对使用 Analysis Toolpack-VBA 不感兴趣。
在此先感谢,斯凯哈尼
我想在 VBA 中使用 Weibull 和广义帕累托分布生成随机数。你能帮我解决一下吗。我对使用 Analysis Toolpack-VBA 不感兴趣。
在此先感谢,斯凯哈尼
这些用户定义的函数可以做你想做的事:
Function RandWeib(fScale As Single, _
fShape As Single, _
Optional bVolatile As Boolean = False) As Single
' shg 2008
' http://en.wikipedia.org/wiki/Weibull_distribution
' Returns a random variate with Weibull distribution
' fScale > 0
' fShape > 0
' By formula: =Scale * -LN(RAND()) ^ (1 / Shape)
If bVolatile Then Application.Volatile
RandWeib = fScale * (-Log(1! - Rnd())) ^ (1! / fShape)
End Function
Function RandPareto(fScale As Single, _
fShape As Single, _
Optional bVolatile As Boolean = False) As Single
' shg 2015
' https://en.wikipedia.org/wiki/Pareto_distribution
' Returns a random variate with Pareto distribution
' fScale > 0
' fShape > 0
' By formula: =Scale / RAND() ^ (1 / Shape)
If bVolatile Then Application.Volatile
RandPareto = fScale / (1! - Rnd()) ^ (1! / fShape)
End Function