使用 copula 分布求和的分位数太慢
尝试使用带有 Beta 边际的内置 copula 分布(Clayton、Frank、Gumbel)创建两个因随机变量之和的分位数表。使用各种方法尝试了 NProbability 和 FindRoot ,但速度不够快。 我需要探索的 copula-marginal 组合的一个示例如下:
nProbClayton[t_?NumericQ, c_?NumericQ] :=
NProbability[ x + y <= t, {x, y} \[Distributed]
CopulaDistribution[{"Clayton", c}, {BetaDistribution[8, 2],
BetaDistribution[8, 2]}]]
进行数值概率的单一评估,
nProbClayton[1.9, 1/10] // Timing // Quiet
对于使用
{4.914, 0.939718}
Vista 64 位 Core2 Duo T9600 2.80GHz 机器 (MMA 8.0.4)
以获得总和的分位数,使用
FindRoot[nProbClayton[q, 1/10] == 1/100, {q, 1, 0, 2}// Timing // Quiet
各种方法
( `Method -> Automatic`, `Method -> "Brent"`, `Method -> "Secant"` )
大约需要一分钟才能找到单个分位数: 计时
{48.781, {q -> 0.918646}}
{50.045, {q -> 0.918646}}
{65.396, {q -> 0.918646}}
对于其他 copula-marginal 组合,计时稍微好一些。
需要:任何改善计时的技巧/方法。
Trying to create a table for quantiles of the sum of two dependent random variables using built-in copula distributions (Clayton, Frank, Gumbel) with Beta marginals. Tried NProbability
and FindRoot
with various methods -- not fast enough.
An example of the copula-marginal combinations I need to explore is the following:
nProbClayton[t_?NumericQ, c_?NumericQ] :=
NProbability[ x + y <= t, {x, y} \[Distributed]
CopulaDistribution[{"Clayton", c}, {BetaDistribution[8, 2],
BetaDistribution[8, 2]}]]
For a single evaluation of the numeric probability using
nProbClayton[1.9, 1/10] // Timing // Quiet
I get
{4.914, 0.939718}
on a Vista 64bit Core2 Duo T9600 2.80GHz machine (MMA 8.0.4)
To get a quantile of the sum, using
FindRoot[nProbClayton[q, 1/10] == 1/100, {q, 1, 0, 2}// Timing // Quiet
with various methods
( `Method -> Automatic`, `Method -> "Brent"`, `Method -> "Secant"` )
takes about a minute to find a single quantile: Timings are
{48.781, {q -> 0.918646}}
{50.045, {q -> 0.918646}}
{65.396, {q -> 0.918646}}
For other copula-marginal combinations timings are marginally better.
Need: any tricks/methods to improve timings.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
参数
c
的 Clayton-Pareto copula 的 CDF 可以根据下式计算:那么,
cdf[c][t1,t2]
是x<< 的概率。 =t1
和y<=t2
。 来计算x+y<=t
的概率这意味着您可以根据我在机器上获得的时间
,请注意,我得到的概率值与原始帖子中的概率值不同。但是,运行
nProbClayton[1.9,0.1]
会产生有关收敛缓慢的警告,这可能意味着原始帖子中的结果不正确。另外,如果我将nProbClayton
的原始定义中的x+y<=t
更改为x+y>t
并计算1 -nProbClayton[1.9,0.1]
我得到0.939825
(没有警告),这与上面的结果相同。对于我再次得到的总和的分位数
,我得到的结果与原始帖子中的结果不同,但与之前类似,将
x+y<=t
更改为x+y>t
并计算FindRoot[nProbClayton[q, 1/10] == 1-1/100, {q, 1, 0, 2}]
返回相同的值q
如上。The CDF of a Clayton-Pareto copula with parameter
c
can be calculated according toThen,
cdf[c][t1,t2]
is the probability thatx<=t1
andy<=t2
. This means that you can calculate the probability thatx+y<=t
according toThe timings I get on my machine are
Note that I get a different value for the probability from the one in the original post. However, running
nProbClayton[1.9,0.1]
produces a warning about slow convergence which could mean that the result in the original post is off. Also, if I changex+y<=t
tox+y>t
in the original definition ofnProbClayton
and calculate1-nProbClayton[1.9,0.1]
I get0.939825
(without warnings) which is the same result as above.For the quantile of the sum I get
Again, I get a different result from the one in the original post but similar to before, changing
x+y<=t
tox+y>t
and calculatingFindRoot[nProbClayton[q, 1/10] == 1-1/100, {q, 1, 0, 2}]
returns the same value forq
as above.