我已經開發了一些代碼,從LogNormalDistribution的產品和StableDistribution生成隨機變元:TransformedDistribution在數學
LNStableRV[{\[Alpha]_, \[Beta]_, \[Gamma]_, \[Sigma]_, \[Delta]_},
n_] := Module[{LNRV, SDRV, LNSRV},
LNRV = RandomVariate[LogNormalDistribution[Log[\[Gamma]], \[Sigma]],
n];
SDRV = RandomVariate[
StableDistribution[\[Alpha], \[Beta], \[Gamma], \[Sigma]], n];
LNRV * SDRV + \[Delta]
]
(* Note the delta serves as a location parameter *)
我覺得這工作得很好:
LNStableRV[{1.5, 1, 1, 0.5, 1}, 50000];
Histogram[%, Automatic, "ProbabilityDensity",
PlotRange -> {{-4, 6}, All}, ImageSize -> 250]
ListPlot[%%, Joined -> True, PlotRange -> All]
現在,我想按照相同的方式創建一個TransformedDistribution,以便我可以在此自定義分佈上使用PDF [],CDF []等,並輕鬆進行繪圖和其他分析。
在文獻中心從一個例子推斷> TransformedDistribution:
\[ScriptCapitalD] =
TransformedDistribution[
u v, {u \[Distributed] ExponentialDistribution[1/2],
v \[Distributed] ExponentialDistribution[1/3]}];
我已經試過這樣:
LogNormalStableDistribution[\[Alpha]_, \[Beta]_, \[Gamma]_, \
\[Sigma]_, \[Delta]_] := Module[{u, v},
TransformedDistribution[
u * v + \[Delta], {u \[Distributed]
LogNormalDistribution[Log[\[Gamma]], \[Sigma]],
v \[Distributed]
StableDistribution[\[Alpha], \[Beta], \[Gamma], \[Sigma]]}]
];
\[ScriptCapitalD] = LogNormalStableDistribution[1.5, 1, 1, 0.5, 1]
,給了我這樣的:
TransformedDistribution[
1 + \[FormalX]1 \[FormalX]2, {\[FormalX]1 \[Distributed]
LogNormalDistribution[0, 0.5], \[FormalX]2 \[Distributed]
StableDistribution[1, 1.5, 1, 1, 0.5]}]
但是當我嘗試繪製分佈的PDF文件,它似乎永遠不會完成(我已經讓它運行不止了一分鐘或2):
Plot[PDF[\[ScriptCapitalD], x], {x, -4, 6}] (* This should plot over the same range as the Histogram above *)
因此,一些問題:
請問我的功能:LogNormalStableDistribution []道理做這樣的事情?
如果是做我:
- 只需要讓繪圖[]運行 長?
- 以某種方式改變它?
- 我該怎麼做才能讓 跑得更快?
如果不是:
- 我需要以不同的方式來處理這個?
- 使用MixtureDistribution?
- 使用別的東西?
任何想法讚賞。
最佳,
Ĵ
我不小心跟隨你的代碼,但您可能會看到PDF [\ [ScriptCapitalD],1]不會返回數字結果... – 2011-03-03 04:48:10
順便說一句...允許我歡迎您來到S tackOverflow並提醒我們通常在這裏做的三件事:1)當你接受幫助時,也嘗試給予它**在你的專業領域回答問題** 2)['閱讀常見問題](http://tinyurl.com/2vycnvr)3)當你看到好的Q&A時,請將它們投票['使用灰色三角形](http://i.imgur.com/kygEP.png),因爲系統的可信度基於用戶通過分享知識獲益。還請記住接受更好地解決您的問題的答案(如果有的話)['通過按複選標記符號](http://i.imgur.com/uqJeW.png) – 2011-03-03 04:48:28