-
Notifications
You must be signed in to change notification settings - Fork 3
/
Systematic.jl
93 lines (82 loc) · 3.51 KB
/
Systematic.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
## --- Dealing with systematic uncertainty
function add_systematic_uncert_UPb(agedistmyr::Array{Float64,1})
λ238 = log(2)/44683 # Jaffey decay constant, 1/Myr
λ238_ = log(2)./(44683 .+ 24 .* randn(size(agedistmyr))) # Jaffey decay with uncertainty 1/Myr
σtracer = 1 .+ (0.03/2/100) .* randn(size(agedistmyr)) # Earthtime tracer uncertainty
r = exp.(agedistmyr .* λ238) .- 1
return log.(r .* σtracer .+ 1) ./ λ238_
end
function add_systematic_uncert_UPb(agedistmyr::Array{Float64,2})
λ238 = log(2)/44683 # Jaffey decay constant, 1/Myr
λ238_ = log(2)./(44683 .+ 24 .* randn(1, size(agedistmyr,2))) # Jaffey decay with uncertainty 1/Myr
σtracer = 1 .+ (0.03/2/100) .* randn(1, size(agedistmyr,2)) # Earthtime tracer uncertainty
r = exp.(agedistmyr .* λ238) .- 1
return log.(r .* σtracer .+ 1) ./ λ238_
end
export add_systematic_uncert_UPb
function add_systematic_uncert_ArAr(agedistmyr::Array{Float64,1})
# Optimization intercalibration values from Renne 2011 reply
# Values
κ = 1.6417E-03
λϵ = 0.5757E-10 # 1/years
λβ = 4.9548E-10 # 1/years
# Uncertainties
σκ = 0.0045E-03
σλϵ = 0.0017E-10 # 1/years
σλβ = 0.0134E-10 # 1/years
# Covariances
σκσλϵ = 7.1903E-19
σκσλβ = -6.5839E-19
σλϵσλβ = -3.4711E-26
# Create a multivariate normal distribution from the decay constant
# means and covariance matrix
μ = [κ, λϵ, λβ]
Σ = [ σκ^2 σκσλϵ σκσλβ;
σκσλϵ σλϵ^2 σλϵσλβ;
σκσλβ σλϵσλβ σλβ^2;]
κλλ_ = rand(MvNormal(μ,Σ),length(agedistmyr)) # Draw from MvNormal
# Exctract individual variables
κ_ = κλλ_[1,:]
λϵ_ = κλλ_[2,:]
λβ_ = κλλ_[3,:]
# Convert age distribution to R distribution. Assume Myr input
λ = λβ + λϵ
Rdist = (exp.(agedistmyr.*λ.*1000000) .- 1) .* λϵ./(κ.*λ)
# Now convert back to age distribution
λ_ = λβ_ .+ λϵ_
return log.(Rdist.*κ_.*λ_./λϵ_ .+ 1)./(λ_.*1000000)
end
function add_systematic_uncert_ArAr(agedistmyr::Array{Float64,2})
# Optimization intercalibration values from Renne 2011 reply
# Values
κ = 1.6417E-03
λϵ = 0.5757E-10
λβ = 4.9548E-10
# Uncertainties
σκ = 0.0045E-03
σλϵ = 0.0017E-10
σλβ = 0.0134E-10
# Covariances
σκσλϵ = 7.1903E-19
σκσλβ = -6.5839E-19
σλϵσλβ = -3.4711E-26
# Create a multivariate normal distribution from the decay constant
# means and covariance matrix
μ = [κ, λϵ, λβ]
Σ = [ σκ^2 σκσλϵ σκσλβ;
σκσλϵ σλϵ^2 σλϵσλβ;
σκσλβ σλϵσλβ σλβ^2;]
κλλ_ = rand(MvNormal(μ,Σ),size(agedistmyr,2)) # Draw from MvNormal
# Exctract individual variables
κ_ = κλλ_[1:1,:]
λϵ_ = κλλ_[2:2,:]
λβ_ = κλλ_[3:3,:]
# Convert age distribution to R distribution
λ = λβ + λϵ
Rdist = (exp.(agedistmyr.*λ.*1000000) .- 1) .* λϵ./(κ.*λ)
# Now convert back to age distribution
λ_ = λβ_ .+ λϵ_
return log.(Rdist.*κ_.*λ_./λϵ_ .+ 1)./(λ_.*1000000)
end
export add_systematic_uncert_ArAr
## --- End of File