Skip to content

Commit 1a8c3b8

Browse files
committed
Increase default cutoff in distribution bootstrapping given better empirical performance
1 parent ae7de37 commit 1a8c3b8

4 files changed

Lines changed: 23 additions & 15 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Chron"
22
uuid = "68885b1f-77b5-52a7-b2e7-6a8014c56b98"
33
authors = ["C. Brenhin Keller <[email protected]>"]
4-
version = "0.6.5"
4+
version = "0.7.0"
55

66
[deps]
77
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"

src/DistMetropolis.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
"""
44
```julia
5-
BootstrapCrystDistributionKDE(smpl::ChronAgeData; cutoff=-0.05, [tpbloss=0])
5+
BootstrapCrystDistributionKDE(smpl::ChronAgeData; cutoff=0.02, [tpbloss=0])
66
```
77
Bootstrap an estimate of the pre-eruptive (or pre-depositional) mineral
88
crystallization distribution shape from a Chron.ChronAgeData object containing
@@ -20,7 +20,7 @@
2020
BootstrappedDistribution = BootstrapCrystDistributionKDE(smpl)
2121
```
2222
"""
23-
function BootstrapCrystDistributionKDE(smpl::ChronAgeData; cutoff::Number=-0.05, tpbloss::Number=0)
23+
function BootstrapCrystDistributionKDE(smpl::ChronAgeData; cutoff::Number=0.02, tpbloss::Number=0)
2424
# Extact variables froms struct
2525
Name = collect(smpl.Name)::Vector{String}
2626
Path = smpl.Path::String
@@ -66,7 +66,7 @@
6666
end
6767
end
6868

69-
# Calculate kernel density estimate, truncated at 0
69+
# Calculate kernel density estimate, truncated at `cutoff`
7070
kd = kde(allscaled,npoints=2^7)
7171
t = kd.x .> cutoff # Ensure sharp cutoff at eruption / deposition
7272
return kd.density[t]
@@ -75,7 +75,7 @@
7575

7676
"""
7777
```julia
78-
BootstrapCrystDistributionKDE(data::AbstractArray, [sigma::AbstractArray]; cutoff=-0.05)
78+
BootstrapCrystDistributionKDE(data::AbstractArray, [sigma::AbstractArray]; cutoff=0.02)
7979
```
8080
Bootstrap an estimate of the pre-eruptive (or pre-depositional) mineral
8181
crystallization distribution shape from a 1- or 2-d array of sample ages
@@ -90,7 +90,7 @@
9090
BootstrappedDistribution = BootstrapCrystDistributionKDE(1:10, ones(10))
9191
```
9292
"""
93-
function BootstrapCrystDistributionKDE(data::AbstractArray{T}; cutoff::Number=-0.05) where {T<:Number}
93+
function BootstrapCrystDistributionKDE(data::AbstractArray{T}; cutoff::Number=0.02) where {T<:Number}
9494
# Load all data points and scale from 0 to 1
9595
allscaled = Vector{float(T)}()
9696
for i=1:size(data,2)
@@ -101,13 +101,13 @@
101101
append!(allscaled, scaled)
102102
end
103103

104-
# Calculate kernel density estimate, truncated at 0
104+
# Calculate kernel density estimate, truncated at `cutoff`
105105
kd = kde(allscaled,npoints=2^7)
106106
t = kd.x .> cutoff
107107
return kd.density[t]
108108
end
109109

110-
function BootstrapCrystDistributionKDE(data::AbstractArray{T}, sigma::AbstractArray{<:Number}; cutoff::Number=-0.05) where {T<:Number}
110+
function BootstrapCrystDistributionKDE(data::AbstractArray{T}, sigma::AbstractArray{<:Number}; cutoff::Number=0.02) where {T<:Number}
111111
# Array to hold stacked, scaled data
112112
allscaled = Vector{float(T)}()
113113

@@ -131,7 +131,7 @@
131131
end
132132
end
133133

134-
# Calculate kernel density estimate, truncated at 0
134+
# Calculate kernel density estimate, truncated at `cutoff`
135135
kd = kde(allscaled,npoints=2^7)
136136
t = kd.x .> cutoff
137137
return kd.density[t]

test/testCoupled.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ smpl = screen_outliers(smpl, maxgap=50; make_plots)
1717
# Distribution boostrapping from chron strat object
1818
BootstrappedDistribution = BootstrapCrystDistributionKDE(smpl)
1919
@test BootstrappedDistribution isa Vector{Float64}
20-
@test BootstrappedDistribution[1] 1.0511396290122654
20+
@test BootstrappedDistribution[1] 1.2986370127270708
2121

2222
# Estimate the eruption age distributions for each sample - - - - - - - -
2323

@@ -138,7 +138,7 @@ smpl = screen_outliers(smpl, maxgap=100; make_plots, discordancemin=-5)
138138

139139
BootstrappedDistribution = BootstrapCrystDistributionKDE(smpl, tpbloss=0)
140140
@test BootstrappedDistribution isa Vector{Float64}
141-
@test BootstrappedDistribution[1] 0.3697041339884247
141+
@test BootstrappedDistribution[1] 0.45349905011835107
142142

143143
# Configure distribution model here
144144
distSteps = 2*10^5 # Number of steps to run in distribution MCMC

test/testDist.jl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,30 @@
44
dist = MeltsVolcanicZirconDistribution ./ nanmean(MeltsVolcanicZirconDistribution)
55
@test Chron.Isoplot.dist_ll(dist, mu, sigma, 100,101) -3.6933357793356576
66

7-
tmindist = metropolis_min(2*10^5, dist, mu, sigma, burnin=10^5)
7+
tmindist = metropolis_min(2*10^5, MeltsVolcanicZirconDistribution, mu, sigma, burnin=10^5)
88
@test isapprox(nanmean(tmindist), 99.925, atol=0.015)
9-
9+
1010
tmindist, tmaxdist, lldist, acceptancedist = metropolis_minmax(2*10^5, MeltsVolcanicZirconDistribution, mu, sigma, burnin=10^5)
1111
@test isapprox(nanmean(tmindist), 99.925, atol=0.015)
1212
@test isapprox(nanmean(tmaxdist), 101.08, atol=0.015)
1313
@test -Inf < mean(lldist) < 0
1414
@test 0 < mean(acceptancedist) < 1
1515

16+
tmindist = metropolis_min(2*10^5, UniformDistribution, mu, sigma, burnin=10^5)
17+
@test isapprox(nanmean(tmindist), 99.961, atol=0.015)
18+
1619
## -- Test distribution bootstrapping
1720

1821
dist = BootstrapCrystDistributionKDE(1:10)
19-
@test all(isapprox.(dist, [0.465404, 0.503149, 0.540308, 0.576485, 0.611314, 0.644472, 0.675691, 0.704756, 0.731516, 0.75588, 0.777815, 0.797345, 0.81454, 0.82951, 0.842398, 0.85337, 0.862605, 0.87029, 0.876611, 0.881749, 0.885873, 0.889136, 0.891676, 0.893612, 0.895043, 0.896047, 0.896684, 0.896993, 0.896993, 0.896684, 0.896047, 0.895043, 0.893612, 0.891676, 0.889136, 0.885873, 0.881749, 0.876611, 0.87029, 0.862605, 0.85337, 0.842398, 0.82951, 0.81454, 0.797345, 0.777815, 0.75588, 0.731516, 0.704756, 0.675691, 0.644472, 0.611314, 0.576485, 0.540308, 0.503149, 0.465404, 0.427489, 0.389826, 0.352829, 0.316888, 0.282361, 0.249559, 0.218742, 0.19011, 0.163804, 0.139901, 0.118424, 0.099338, 0.082567, 0.067992, 0.055465, 0.044819, 0.03587, 0.028432, 0.022318, 0.017347, 0.01335, 0.010173, 0.007675, 0.005732, 0.004238, 0.003102, 0.002247, 0.001612, 0.001145, 0.000806, 0.000563, 0.000392, 0.000275, 0.000197, 0.00015, 0.000128], atol=0.00001))
22+
@test all(isapprox.(dist, [0.611314, 0.644472, 0.675691, 0.704756, 0.731516, 0.75588, 0.777815, 0.797345, 0.81454, 0.82951, 0.842398, 0.85337, 0.862605, 0.87029, 0.876611, 0.881749, 0.885873, 0.889136, 0.891676, 0.893612, 0.895043, 0.896047, 0.896684, 0.896993, 0.896993, 0.896684, 0.896047, 0.895043, 0.893612, 0.891676, 0.889136, 0.885873, 0.881749, 0.876611, 0.87029, 0.862605, 0.85337, 0.842398, 0.82951, 0.81454, 0.797345, 0.777815, 0.75588, 0.731516, 0.704756, 0.675691, 0.644472, 0.611314, 0.576485, 0.540308, 0.503149, 0.465404, 0.427489, 0.389826, 0.352829, 0.316888, 0.282361, 0.249559, 0.218742, 0.19011, 0.163804, 0.139901, 0.118424, 0.099338, 0.082567, 0.067992, 0.055465, 0.044819, 0.03587, 0.028432, 0.022318, 0.017347, 0.01335, 0.010173, 0.007675, 0.005732, 0.004238, 0.003102, 0.002247, 0.001612, 0.001145, 0.000806, 0.000563, 0.000392, 0.000275, 0.000197, 0.00015, 0.000128], atol=0.00001))
2023

2124
dist = BootstrapCrystDistributionKDE(1:10, ones(10))
22-
@test all(isapprox.(dist, [0.500228, 0.535143, 0.569056, 0.601647, 0.632641, 0.661805, 0.688961, 0.713982, 0.736794, 0.757375, 0.775748, 0.79198, 0.806169, 0.818443, 0.828947, 0.837842, 0.845291, 0.851459, 0.856502, 0.86057, 0.863796, 0.866299, 0.868179, 0.869517, 0.870375, 0.870794, 0.870794, 0.870375, 0.869517, 0.868179, 0.866299, 0.863796, 0.86057, 0.856502, 0.851459, 0.845291, 0.837842, 0.828947, 0.818443, 0.806169, 0.79198, 0.775748, 0.757375, 0.736794, 0.713982, 0.688961, 0.661805, 0.632641, 0.601647, 0.569056, 0.535143, 0.500228, 0.464656, 0.428798, 0.39303, 0.357728, 0.323251, 0.289935, 0.258079, 0.227938, 0.199721, 0.173583, 0.149624, 0.127894, 0.108393, 0.091075, 0.075858, 0.062627, 0.051244, 0.041553, 0.03339, 0.026585, 0.020972, 0.016391, 0.012691, 0.009734, 0.007396, 0.005566, 0.004149, 0.003064, 0.002241, 0.001623, 0.001166, 0.00083, 0.000587, 0.000415, 0.000295, 0.000215, 0.000166, 0.000143], atol=0.00001))
25+
@test all(isapprox.(dist, [0.601647, 0.632641, 0.661805, 0.688961, 0.713982, 0.736794, 0.757375, 0.775748, 0.79198, 0.806169, 0.818443, 0.828947, 0.837842, 0.845291, 0.851459, 0.856502, 0.86057, 0.863796, 0.866299, 0.868179, 0.869517, 0.870375, 0.870794, 0.870794, 0.870375, 0.869517, 0.868179, 0.866299, 0.863796, 0.86057, 0.856502, 0.851459, 0.845291, 0.837842, 0.828947, 0.818443, 0.806169, 0.79198, 0.775748, 0.757375, 0.736794, 0.713982, 0.688961, 0.661805, 0.632641, 0.601647, 0.569056, 0.535143, 0.500228, 0.464656, 0.428798, 0.39303, 0.357728, 0.323251, 0.289935, 0.258079, 0.227938, 0.199721, 0.173583, 0.149624, 0.127894, 0.108393, 0.091075, 0.075858, 0.062627, 0.051244, 0.041553, 0.03339, 0.026585, 0.020972, 0.016391, 0.012691, 0.009734, 0.007396, 0.005566, 0.004149, 0.003064, 0.002241, 0.001623, 0.001166, 0.00083, 0.000587, 0.000415, 0.000295, 0.000215, 0.000166, 0.000143], atol=0.00001))
26+
27+
mu, sigma = collect(100:0.1:101), 0.01*ones(11);
28+
tmindist = metropolis_min(2*10^5, dist, mu, sigma, burnin=10^5)
29+
@test isapprox(nanmean(tmindist), 99.961, atol=0.015)
30+
2331

2432
## -- Test systematic uncertainty propagation
2533

0 commit comments

Comments
 (0)