@@ -2,41 +2,20 @@ using BenchmarkTools
22using Copulas
33using Distributions
44using StableRNGs
5+ const rng = StableRNG (123 )
56
67# PkgBenchmark entrypoint; must define SUITE
78const SUITE = BenchmarkGroup ()
8- module M
9- using StableRNGs
10- const rng = StableRNG (123 )
11- end
129
13- # Separate SklarDist benchmarks on a single representative model (Clayton d=5)
14- let rng = StableRNG (321 )
15- top = SUITE[" sklar" ] = BenchmarkGroup ()
16- C = ClaytonCopula (5 , 2.0 )
17- m = (Distributions. Normal (), Distributions. LogNormal (), Distributions. Gamma (2 ,2 ), Distributions. Beta (2 ,5 ), Distributions. Uniform ())
18- S = SklarDist (C, m)
19- X = rand (rng, S, 128 )
20- U = pseudos (X)
21- top[" rand/128" ] = @benchmarkable rand ($ rng, $ S, 128 )
22- top[" cdf/128" ] = @benchmarkable cdf ($ S, $ X)
23- top[" pdf/128" ] = @benchmarkable pdf ($ S, $ X)
24- top[" rosenblatt/128" ] = @benchmarkable rosenblatt ($ S, $ X)
25- V = rand (rng, 5 , 128 )
26- top[" inverse_rosenblatt/128" ] = @benchmarkable inverse_rosenblatt ($ S, $ V)
27- # Fitting pathways (keep light)
28- top[" fit/ifm" ] = @benchmarkable Distributions. fit (CopulaModel, SklarDist{ClaytonCopula, typeof (m)}, $ X; sklar_method= :ifm , copula_method= :itau , summaries= false )
29- top[" fit/ecdf" ] = @benchmarkable Distributions. fit (CopulaModel, SklarDist{ClaytonCopula, typeof (m)}, $ X; sklar_method= :ecdf , copula_method= :itau , summaries= false )
30- end
3110
3211const EXAMPLES = unique ([
3312 AMHCopula (2 ,- 1.0 ),
34- AMHCopula (2 ,- rand (M . rng)),
13+ AMHCopula (2 ,- rand (rng)),
3514 AMHCopula (2 ,0.7 ),
36- AMHCopula (2 ,rand (M . rng)),
37- AMHCopula (3 ,- rand (M . rng)* 0.1 ),
15+ AMHCopula (2 ,rand (rng)),
16+ AMHCopula (3 ,- rand (rng)* 0.1 ),
3817 AMHCopula (3 ,0.6 ),
39- AMHCopula (3 ,rand (M . rng)),
18+ AMHCopula (3 ,rand (rng)),
4019 AMHCopula (4 ,- 0.01 ),
4120 ArchimaxCopula (2 , Copulas. BB1Generator (1.3 , 1.4 ), Copulas. AsymGalambosTail (0.35 , 0.65 , 0.3 )),
4221 ArchimaxCopula (2 , Copulas. BB1Generator (1.3 , 1.4 ), Copulas. GalambosTail (0.7 )),
@@ -110,33 +89,33 @@ const EXAMPLES = unique([
11089 ArchimaxCopula (2 , Copulas. JoeGenerator (2.5 ), Copulas. LogTail (2.0 )),
11190 ArchimedeanCopula (10 ,i𝒲 (Dirac (1 ),10 )),
11291 ArchimedeanCopula (10 ,i𝒲 (MixtureModel ([Dirac (1 ), Dirac (2 )]),11 )),
113- ArchimedeanCopula (2 , EmpiricalGenerator (randn (M . rng, 4 , 150 ))),
92+ ArchimedeanCopula (2 , EmpiricalGenerator (randn (rng, 4 , 150 ))),
11493 ArchimedeanCopula (2 ,i𝒲 (LogNormal (),2 )),
11594 ArchimedeanCopula (2 ,i𝒲 (LogNormal (3 ),5 )),
11695 ArchimedeanCopula (2 ,i𝒲 (Pareto (1 ),5 )),
117- ArchimedeanCopula (3 , EmpiricalGenerator (randn (M . rng, 3 , 200 ))),
96+ ArchimedeanCopula (3 , EmpiricalGenerator (randn (rng, 3 , 200 ))),
11897 AsymGalambosCopula (2 , 0.1 , 0.2 , 0.6 ),
11998 AsymGalambosCopula (2 , 0.6129496106778634 , 0.820474440393214 , 0.22304578643880224 ),
120- AsymGalambosCopula (2 , 10 + 5 * rand (M . rng), 1.0 , 1.0 ),
121- AsymGalambosCopula (2 , 10 + 5 * rand (M . rng), rand (M . rng), rand (M . rng)),
99+ AsymGalambosCopula (2 , 10 + 5 * rand (rng), 1.0 , 1.0 ),
100+ AsymGalambosCopula (2 , 10 + 5 * rand (rng), rand (rng), rand (rng)),
122101 AsymGalambosCopula (2 , 11.647356700032505 , 0.6195348270893413 , 0.4197760589260566 ),
123102 AsymGalambosCopula (2 , 5.0 , 0.8 , 0.3 ),
124- AsymGalambosCopula (2 , 5 + 4 * rand (M . rng), 1.0 , 1.0 ),
125- AsymGalambosCopula (2 , 5 + 4 * rand (M . rng), rand (M . rng), rand (M . rng)),
103+ AsymGalambosCopula (2 , 5 + 4 * rand (rng), 1.0 , 1.0 ),
104+ AsymGalambosCopula (2 , 5 + 4 * rand (rng), rand (rng), rand (rng)),
126105 AsymGalambosCopula (2 , 8.810168494949659 , 0.5987759444612732 , 0.5391280234619427 ),
127- AsymGalambosCopula (2 , rand (M . rng), 1.0 , 1.0 ),
128- AsymGalambosCopula (2 , rand (M . rng), rand (M . rng), rand (M . rng)),
106+ AsymGalambosCopula (2 , rand (rng), 1.0 , 1.0 ),
107+ AsymGalambosCopula (2 , rand (rng), rand (rng), rand (rng)),
129108 AsymLogCopula (2 , 1.0 , 0.0 , 0.0 ),
130109 AsymLogCopula (2 , 1.0 , 1.0 , 1.0 ),
131- AsymLogCopula (2 , 1.0 , rand (M . rng), rand (M . rng)),
110+ AsymLogCopula (2 , 1.0 , rand (rng), rand (rng)),
132111 AsymLogCopula (2 , 1.2 , 0.3 ,0.6 ),
133112 AsymLogCopula (2 , 1.5 , 0.5 , 0.2 ),
134- AsymLogCopula (2 , 1 + 4 * rand (M . rng), 0.0 , 0.0 ),
135- AsymLogCopula (2 , 1 + 4 * rand (M . rng), 1.0 , 1.0 ),
136- AsymLogCopula (2 , 1 + 4 * rand (M . rng), rand (M . rng), rand (M . rng)),
137- AsymLogCopula (2 , 10 + 5 * rand (M . rng), 0.0 , 0.0 ),
138- AsymLogCopula (2 , 10 + 5 * rand (M . rng), 1.0 , 1.0 ),
139- AsymLogCopula (2 , 10 + 5 * rand (M . rng), rand (M . rng), rand (M . rng)),
113+ AsymLogCopula (2 , 1 + 4 * rand (rng), 0.0 , 0.0 ),
114+ AsymLogCopula (2 , 1 + 4 * rand (rng), 1.0 , 1.0 ),
115+ AsymLogCopula (2 , 1 + 4 * rand (rng), rand (rng), rand (rng)),
116+ AsymLogCopula (2 , 10 + 5 * rand (rng), 0.0 , 0.0 ),
117+ AsymLogCopula (2 , 10 + 5 * rand (rng), 1.0 , 1.0 ),
118+ AsymLogCopula (2 , 10 + 5 * rand (rng), rand (rng), rand (rng)),
140119 AsymMixedCopula (2 , 0.1 , 0.2 ),
141120 AsymMixedCopula (2 , 0.12 , 0.13 ),
142121 BB10Copula (2 , 1.5 , 0.7 ),
@@ -169,27 +148,27 @@ const EXAMPLES = unique([
169148 BC2Copula (2 , 0.7 ,0.3 ),
170149 BC2Copula (2 , 1.0 , 0.0 ),
171150 BC2Copula (2 , 1 / 2 ,1 / 2 ),
172- BC2Copula (2 , rand (M . rng), rand (M . rng)),
151+ BC2Copula (2 , rand (rng), rand (rng)),
173152 BernsteinCopula (ArchimaxCopula (2 , Copulas. FrankGenerator (0.8 ), Copulas. HuslerReissTail (0.6 )); m= 5 ),
174153 BernsteinCopula (ClaytonCopula (3 , 3.3 ); m= 5 ),
175154 BernsteinCopula (GalambosCopula (2 , 2.5 ); m= 5 ),
176155 BernsteinCopula (GaussianCopula (2 , 0.3 ); m= 5 ),
177156 BernsteinCopula (IndependentCopula (4 ); m= 5 ),
178157 BernsteinCopula (IndependentCopula (4 ); m= 5 ),
179- BernsteinCopula (randn (M . rng, 2 ,100 ), pseudo_values= false ),
180- BetaCopula (randn (M . rng, 2 ,100 )),
181- BetaCopula (randn (M . rng, 3 ,100 )),
182- CheckerboardCopula (randn (M . rng, 2 ,100 ); pseudo_values= false ),
183- CheckerboardCopula (randn (M . rng, 3 ,100 ); pseudo_values= false ),
184- CheckerboardCopula (randn (M . rng, 4 ,100 ); pseudo_values= false ),
158+ BernsteinCopula (randn (rng, 2 ,100 ), pseudo_values= false ),
159+ BetaCopula (randn (rng, 2 ,100 )),
160+ BetaCopula (randn (rng, 3 ,100 )),
161+ CheckerboardCopula (randn (rng, 2 ,100 ); pseudo_values= false ),
162+ CheckerboardCopula (randn (rng, 3 ,100 ); pseudo_values= false ),
163+ CheckerboardCopula (randn (rng, 4 ,100 ); pseudo_values= false ),
185164 ClaytonCopula (2 ,- 0.7 ),
186- ClaytonCopula (2 ,- log (rand (M . rng))),
187- ClaytonCopula (2 ,- rand (M . rng)),
165+ ClaytonCopula (2 ,- log (rand (rng))),
166+ ClaytonCopula (2 ,- rand (rng)),
188167 ClaytonCopula (2 ,7 ),
189- ClaytonCopula (3 ,- log (rand (M . rng))),
190- ClaytonCopula (3 ,- rand (M . rng)/ 2 ),
191- ClaytonCopula (4 ,- log (rand (M . rng))),
192- ClaytonCopula (4 ,- rand (M . rng)/ 3 ),
168+ ClaytonCopula (3 ,- log (rand (rng))),
169+ ClaytonCopula (3 ,- rand (rng)/ 2 ),
170+ ClaytonCopula (4 ,- log (rand (rng))),
171+ ClaytonCopula (4 ,- rand (rng)/ 3 ),
193172 ClaytonCopula (4 ,7. ),
194173 Copulas. SubsetCopula (RafteryCopula (3 , 0.5 ), (2 ,1 )),
195174 CuadrasAugeCopula (2 , 0.0 ),
@@ -198,54 +177,54 @@ const EXAMPLES = unique([
198177 CuadrasAugeCopula (2 , 0.7103550345192344 ),
199178 CuadrasAugeCopula (2 , 0.8 ),
200179 CuadrasAugeCopula (2 , 1.0 ),
201- CuadrasAugeCopula (2 , rand (M . rng)),
180+ CuadrasAugeCopula (2 , rand (rng)),
202181 EmpiricalCopula (randn (2 ,10 ),pseudo_values= false ),
203182 EmpiricalCopula (randn (2 ,20 ),pseudo_values= false ),
204- EmpiricalEVCopula (randn (M . rng, 2 ,10 ); method= :cfg , pseudo_values= false ),
205- EmpiricalEVCopula (randn (M . rng, 2 ,10 ); method= :ols , pseudo_values= false ),
206- EmpiricalEVCopula (randn (M . rng, 2 ,10 ); method= :pickands , pseudo_values= false ),
207- EmpiricalEVCopula (randn (M . rng, 2 ,20 ); method= :cfg , pseudo_values= false ),
208- EmpiricalEVCopula (randn (M . rng, 2 ,20 ); method= :ols , pseudo_values= false ),
209- EmpiricalEVCopula (randn (M . rng, 2 ,20 ); method= :pickands , pseudo_values= false ),
183+ EmpiricalEVCopula (randn (rng, 2 ,10 ); method= :cfg , pseudo_values= false ),
184+ EmpiricalEVCopula (randn (rng, 2 ,10 ); method= :ols , pseudo_values= false ),
185+ EmpiricalEVCopula (randn (rng, 2 ,10 ); method= :pickands , pseudo_values= false ),
186+ EmpiricalEVCopula (randn (rng, 2 ,20 ); method= :cfg , pseudo_values= false ),
187+ EmpiricalEVCopula (randn (rng, 2 ,20 ); method= :ols , pseudo_values= false ),
188+ EmpiricalEVCopula (randn (rng, 2 ,20 ); method= :pickands , pseudo_values= false ),
210189 FGMCopula (2 , 0.0 ),
211- FGMCopula (2 , rand (M . rng)),
190+ FGMCopula (2 , rand (rng)),
212191 FGMCopula (2 ,1 ),
213192 FGMCopula (3 , [0.3 ,0.3 ,0.3 ,0.3 ]),
214193 FGMCopula (3 ,[0.1 ,0.2 ,0.3 ,0.4 ]),
215194 FrankCopula (2 ,- 5 ),
216195 FrankCopula (2 ,0.5 ),
217- FrankCopula (2 ,1 - log (rand (M . rng))),
196+ FrankCopula (2 ,1 - log (rand (rng))),
218197 FrankCopula (2 ,1.0 ),
219- FrankCopula (3 ,1 - log (rand (M . rng))),
198+ FrankCopula (3 ,1 - log (rand (rng))),
220199 FrankCopula (3 ,1.0 ),
221200 FrankCopula (3 ,12 ),
222- FrankCopula (4 ,1 - log (rand (M . rng))),
201+ FrankCopula (4 ,1 - log (rand (rng))),
223202 FrankCopula (4 ,1.0 ),
224203 FrankCopula (4 ,150 ),
225204 FrankCopula (4 ,30 ),
226205 FrankCopula (4 ,37 ),
227206 GalambosCopula (2 , 0.3 ),
228- GalambosCopula (2 , 1 + 4 * rand (M . rng)),
207+ GalambosCopula (2 , 1 + 4 * rand (rng)),
229208 GalambosCopula (2 , 120 ),
230209 GalambosCopula (2 , 20 ),
231210 GalambosCopula (2 , 210 ),
232211 GalambosCopula (2 , 4.3 ),
233- GalambosCopula (2 , 5 + 5 * rand (M . rng)),
212+ GalambosCopula (2 , 5 + 5 * rand (rng)),
234213 GalambosCopula (2 , 80 ),
235- GalambosCopula (2 , rand (M . rng)),
214+ GalambosCopula (2 , rand (rng)),
236215 GaussianCopula ([1 0.5 ; 0.5 1 ]),
237216 GaussianCopula ([1 0.7 ; 0.7 1 ]),
238217 GumbelBarnettCopula (2 ,1.0 ),
239- GumbelBarnettCopula (2 ,rand (M . rng)),
218+ GumbelBarnettCopula (2 ,rand (rng)),
240219 GumbelBarnettCopula (3 ,0.1 ),
241220 GumbelBarnettCopula (3 ,0.35 ),
242- GumbelBarnettCopula (3 ,rand (M . rng)* 0.38 ),
221+ GumbelBarnettCopula (3 ,rand (rng)* 0.38 ),
243222 GumbelBarnettCopula (4 ,0.2 ),
244223 GumbelCopula (2 , 1.2 ),
245- GumbelCopula (2 ,1 - log (rand (M . rng))),
224+ GumbelCopula (2 ,1 - log (rand (rng))),
246225 GumbelCopula (2 ,8 ),
247- GumbelCopula (3 ,1 - log (rand (M . rng))),
248- GumbelCopula (4 ,1 - log (rand (M . rng))),
226+ GumbelCopula (3 ,1 - log (rand (rng))),
227+ GumbelCopula (4 ,1 - log (rand (rng))),
249228 GumbelCopula (4 ,100 ),
250229 GumbelCopula (4 ,20 ),
251230 GumbelCopula (4 ,7 ),
@@ -256,22 +235,22 @@ const EXAMPLES = unique([
256235 HuslerReissCopula (2 , 5.319851350643586 ),
257236 IndependentCopula (2 ),
258237 IndependentCopula (3 ),
259- InvGaussianCopula (2 ,- log (rand (M . rng))),
238+ InvGaussianCopula (2 ,- log (rand (rng))),
260239 InvGaussianCopula (2 ,1.0 ),
261- InvGaussianCopula (2 ,rand (M . rng)),
262- InvGaussianCopula (3 ,- log (rand (M . rng))),
263- InvGaussianCopula (3 ,rand (M . rng)),
264- InvGaussianCopula (4 ,- log (rand (M . rng))),
240+ InvGaussianCopula (2 ,rand (rng)),
241+ InvGaussianCopula (3 ,- log (rand (rng))),
242+ InvGaussianCopula (3 ,rand (rng)),
243+ InvGaussianCopula (4 ,- log (rand (rng))),
265244 InvGaussianCopula (4 ,0.05 ),
266245 InvGaussianCopula (4 ,1.0 ),
267- JoeCopula (2 ,1 - log (rand (M . rng))),
246+ JoeCopula (2 ,1 - log (rand (rng))),
268247 JoeCopula (2 ,3 ),
269248 JoeCopula (2 ,Inf ),
270- JoeCopula (3 ,1 - log (rand (M . rng))),
249+ JoeCopula (3 ,1 - log (rand (rng))),
271250 JoeCopula (3 ,7 ),
272- JoeCopula (4 ,1 - log (rand (M . rng))),
251+ JoeCopula (4 ,1 - log (rand (rng))),
273252 LogCopula (2 , 1.5 ),
274- LogCopula (2 , 1 + 9 * rand (M . rng)),
253+ LogCopula (2 , 1 + 9 * rand (rng)),
275254 LogCopula (2 , 5.5 ),
276255 MCopula (2 ),
277256 MCopula (4 ),
@@ -283,7 +262,7 @@ const EXAMPLES = unique([
283262 MOCopula (2 , 0.5 , 0.5 , 0.5 ),
284263 MOCopula (2 , 0.5960710257852946 , 0.3313524247810329 , 0.09653466861970061 ),
285264 MOCopula (2 , 1.0 , 1.0 , 1.0 ),
286- MOCopula (2 , rand (M . rng), rand (M . rng), rand (M . rng)),
265+ MOCopula (2 , rand (rng), rand (rng), rand (rng)),
287266 PlackettCopula (0.5 ),
288267 PlackettCopula (0.8 ),
289268 PlackettCopula (2.0 ),
@@ -298,18 +277,18 @@ const EXAMPLES = unique([
298277 tEVCopula (2 , 2.0 , 0.5 ),
299278 tEVCopula (2 , 3.0 , 0.0 ),
300279 tEVCopula (2 , 4.0 , 0.5 ),
301- tEVCopula (2 , 4 + 6 * rand (M . rng), - 0.9 + 1.9 * rand (M . rng)),
280+ tEVCopula (2 , 4 + 6 * rand (rng), - 0.9 + 1.9 * rand (rng)),
302281 tEVCopula (2 , 5.0 , - 0.5 ),
303282 tEVCopula (2 , 5.466564460573727 , - 0.6566645244416698 ),
304283 WCopula (2 ),
305- ])
284+ ]);
306285
307286let rng = StableRNG (123 )
308287 top = SUITE[" copulas" ] = BenchmarkGroup ()
309288 # helper to get stable display names
310289 _show_name (C) = sprint (show, C)
311290 _base_from_show (s:: AbstractString ) = (m = match (r" ^[^\s (]+" , s); m === nothing ? s : m. match)
312- for C in EXAMPLES
291+ for C in EXAMPLES[ 1 : 2 ] # only the first two for the moment to see.
313292 CT, d = typeof (C), length (C)
314293 name_full = _show_name (C)
315294 name_base = _base_from_show (name_full)
@@ -363,3 +342,23 @@ let rng = StableRNG(123)
363342 end
364343 end
365344end
345+
346+
347+ # Separate SklarDist benchmarks on a single representative model (Clayton d=5)
348+ # let rng = StableRNG(321)
349+ # top = SUITE["sklar"] = BenchmarkGroup()
350+ # C = ClaytonCopula(5, 2.0)
351+ # m = (Distributions.Normal(), Distributions.LogNormal(), Distributions.Gamma(2,2), Distributions.Beta(2,5), Distributions.Uniform())
352+ # S = SklarDist(C, m)
353+ # X = rand(rng, S, 128)
354+ # U = pseudos(X)
355+ # top["rand/128"] = @benchmarkable rand($rng, $S, 128)
356+ # top["cdf/128"] = @benchmarkable cdf($S, $X)
357+ # top["pdf/128"] = @benchmarkable pdf($S, $X)
358+ # top["rosenblatt/128"] = @benchmarkable rosenblatt($S, $X)
359+ # V = rand(rng, 5, 128)
360+ # top["inverse_rosenblatt/128"] = @benchmarkable inverse_rosenblatt($S, $V)
361+ # # Fitting pathways (keep light)
362+ # top["fit/ifm"] = @benchmarkable Distributions.fit(CopulaModel, SklarDist{ClaytonCopula, typeof(m)}, $X; sklar_method=:ifm, copula_method=:itau, summaries=false)
363+ # top["fit/ecdf"] = @benchmarkable Distributions.fit(CopulaModel, SklarDist{ClaytonCopula, typeof(m)}, $X; sklar_method=:ecdf, copula_method=:itau, summaries=false)
364+ # end
0 commit comments