Performance 使用copula分布的和的分位数太慢
尝试使用内置的copula分布(Clayton、Frank、Gumbel)和Beta边缘创建两个相依随机变量之和的分位数表。用各种方法尝试了Performance 使用copula分布的和的分位数太慢,performance,wolfram-mathematica,mathematica-8,Performance,Wolfram Mathematica,Mathematica 8,尝试使用内置的copula分布(Clayton、Frank、Gumbel)和Beta边缘创建两个相依随机变量之和的分位数表。用各种方法尝试了n可能性和FindRoot——速度不够快。 我需要探讨的copula边际组合示例如下: nProbClayton[t_?NumericQ, c_?NumericQ] := NProbability[ x + y <= t, {x, y} \[Distributed] CopulaDistrib
n可能性
和FindRoot
——速度不够快。
我需要探讨的copula边际组合示例如下:
nProbClayton[t_?NumericQ, c_?NumericQ] :=
NProbability[ x + y <= t, {x, y} \[Distributed]
CopulaDistribution[{"Clayton", c}, {BetaDistribution[8, 2],
BetaDistribution[8, 2]}]]
我明白了
{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边际组合,计时稍微好一些
需要:改进计时的任何技巧/方法 参数为
c
的Clayton-Pareto copula的CDF可以根据
cdf[c_] := Module[{c1 = CDF[BetaDistribution[8, 2]]},
(c1[#1]^(-1/c) + c1[#2]^(-1/c) - 1)^(-c) &]
prob[t_?NumericQ, c_?NumericQ] :=
NIntegrate[Derivative[1, 0][cdf[c]][x, t - x], {x, 0, t}]
那么,
cdf[c][t1,t2]
就是x非常感谢你的概率!这就是我所希望的方法。对于q
,我得到了类似的计时和相同的最终结果,但是prob[.1,1.9]//计时给出了(*=>{0.1089999,1.647600208083803
*^-10}*)在我的机器上。@kguler应该是prob[1.9,0.1]
。我在以前的版本中颠倒了c
和t
,但我忘了在我的答案中更改它。我现在已经修复了它。对cdf
进行了一个小小的修改,将其修改为cdf[c#]:=Module[{c1=cdf[BetaDistribution[8,2]],c2=cdf[BetaDistribution[8,2]},(c1[#1]^(-1/c)+c2[#2]^(-1/c)-1^(-c)&
可以作为任意二元分布的模板。关于
prob[t_?NumericQ, c_?NumericQ] :=
NIntegrate[Derivative[1, 0][cdf[c]][x, t - x], {x, 0, t}]
prob[1.9, .1] // Timing
(* ==> {0.087518, 0.939825} *)
FindRoot[prob[q, .1] == .01, {q, 1, 0, 2}] // Timing
(* ==> {1.19123, {q -> 0.912486}} *)