Skip to content

Commit e538d37

Browse files
committed
Rewrite asymptotic test more efficiently (#29)
bors r+
1 parent 7876d43 commit e538d37

File tree

7 files changed

+222
-109
lines changed

7 files changed

+222
-109
lines changed

Project.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
name = "CalibrationTests"
22
uuid = "2818745e-0823-50c7-bc2d-405ac343d48b"
33
authors = ["David Widmann <[email protected]>"]
4-
version = "0.4.4"
4+
version = "0.5.0"
55

66
[deps]
77
CalibrationErrors = "33913031-fe46-5864-950f-100836f47845"
88
HypothesisTests = "09f84164-cd44-5f33-b23f-e6b0d136a0d5"
9+
KernelFunctions = "ec8451be-7e33-11e9-00cf-bbf324bd1392"
910
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1011
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
12+
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1113
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1214
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
1315
StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
@@ -16,6 +18,8 @@ UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
1618
[compat]
1719
CalibrationErrors = "0.5.12"
1820
HypothesisTests = "0.8, 0.9, 0.10"
21+
KernelFunctions = "0.8.20"
22+
Reexport = "1"
1923
StatsBase = "0.32, 0.33"
2024
StatsFuns = "0.8, 0.9"
2125
UnPack = "0.1, 1"

src/CalibrationTests.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
module CalibrationTests
22

3-
using CalibrationErrors
3+
using Reexport
4+
5+
@reexport using CalibrationErrors
46
using HypothesisTests
7+
@reexport using KernelFunctions
58
using UnPack
69
using StatsBase
710
using StatsFuns
@@ -27,6 +30,4 @@ include("skce/distribution_free.jl")
2730

2831
include("cme.jl")
2932

30-
include("deprecated.jl")
31-
3233
end # module

src/consistency.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ function consistency_resampling_ccdf_direct(
8181

8282
# for each resampling step
8383
n = 0
84+
sampler = Random.Sampler(rng, 1:nsamples)
8485
@inbounds for _ in 1:bootstrap_iters
8586
# resample data
86-
rand!(rng, resampledidxs, 1:nsamples)
87+
rand!(rng, resampledidxs, sampler)
8788
for j in 1:nsamples
8889
# resample predictions
8990
idx = resampledidxs[j]
@@ -136,16 +137,18 @@ function consistency_resampling_ccdf_alias(
136137

137138
# for each resampling step
138139
n = 0
140+
sampler_predictions = Random.Sampler(rng, 1:nsamples)
141+
sampler_targets = Random.Sampler(rng, 1:nclasses)
139142
@inbounds for _ in 1:bootstrap_iters
140143
# resample data
141-
rand!(rng, resampledidxs, 1:nsamples)
144+
rand!(rng, resampledidxs, sampler_predictions)
142145
for j in 1:nsamples
143146
# resample predictions
144147
idx = resampledidxs[j]
145148
resampledpredictions[j] = predictions[idx]
146149

147150
# resample targets
148-
target = rand(rng, 1:nclasses)
151+
target = rand(rng, sampler_targets)
149152
resampledtargets[j] =
150153
rand(rng) < accept[idx][target] ? target : alias[idx][target]
151154
end

src/deprecated.jl

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)