【问题标题】:TransformedDistribution in MathematicaMathematica 中的变换分布
【发布时间】:2021-06-04 00:12:52
【问题描述】:

我已经开发了一些代码来从 LogNormalDistribution 和 StableDistribution 的乘积中生成随机变量:

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[] 做这种事情有意义吗?

如果是,我会:

  • 只需要让 Plot[] 运行 更长?
  • 以某种方式改变它?
  • 我该怎么做才能做到这一点 跑得更快?

如果没有:

  • 我需要以不同的方式解决这个问题吗?
  • 使用 MixtureDistribution?
  • 使用别的东西?

【问题讨论】:

  • 我没有仔细遵循您的代码,但您可能会看到 PDF[[ScriptCapitalD],1] 没有返回数字结果...
  • 顺便说一句 ... 请允许我欢迎您使用 StackOverflow 并提醒我们通常在这里做的三件事:1)当您收到帮助时,请尝试在 回答问题你的专业领域 2) Read the FAQs 3) 当你看到好的问答时,给他们投票using the gray triangles,因为系统的可信度是基于用户通过分享他们的知识而获得的声誉。还记得接受更好地解决您的问题的答案,如果有的话,by pressing the checkmark sign

标签: wolfram-mathematica distribution


【解决方案1】:

您使用转换分布的方法很好,但由于分布的PDF 不以封闭形式存在,PDF[TransformedDistribution[..],x] 不是要走的路,因为每个x 都会应用一个符号求解器。最好按摩您的发行版以获取 pdf。令 X 为 LogNormal-Stable 随机变量。那么

CDF[LogNormalStableDistribution[params], x] == Probability[X <= x] 

但是X==U*V + delta 因此X&lt;=x 转换为V&lt;=(x-delta)/U。这给了

LogNormalStableCDF[{\[Alpha]_, \[Beta]_, \[Gamma]_, \[Sigma]_, \
\[Delta]_}, x_Real] := 
 Block[{u}, 
  NExpectation[
   CDF[StableDistribution[\[Alpha], \[Beta], \[Gamma], \[Sigma]], (x \
- \[Delta])/u], 
   u \[Distributed] LogNormalDistribution[Log[\[Gamma]], \[Sigma]]]]

对x 进行微分,我们得到PDF:

LogNormalStablePDF[{\[Alpha]_, \[Beta]_, \[Gamma]_, \[Sigma]_, \
\[Delta]_}, x_Real] := 
 Block[{u}, 
  NExpectation[
   PDF[StableDistribution[\[Alpha], \[Beta], \[Gamma], \[Sigma]], (x \
- \[Delta])/u]/u, 
   u \[Distributed] LogNormalDistribution[Log[\[Gamma]], \[Sigma]]]]

使用这个,这里是情节

【讨论】:

  • Sasha -- 感谢您的解决方案和解释。
猜你喜欢
  • 1970-01-01
  • 2012-03-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-22
  • 1970-01-01
  • 2014-11-01
相关资源
最近更新 更多