Skip to content

Commit f0dc9b4

Browse files
committed
Add method for strat_ll of arbitrary Distributions
1 parent da32800 commit f0dc9b4

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/StratMetropolis.jl

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,18 @@
434434
## --- # Internals of the Markov chain
435435

436436
# Use dispatch to let us reduce duplication
437-
strat_ll(x, ages::Vector{<:BilinearExponential}) = bilinear_exponential_ll(x, ages)
438-
strat_ll(x, ages::Vector{<:Radiocarbon}) = interpolate_ll(x, ages)
439-
strat_ll(x, ages::Vector{<:Normal}) = normpdf_ll(x, ages)
437+
strat_ll(x, ages::AbstractVector{<:BilinearExponential}) = bilinear_exponential_ll(x, ages)
438+
strat_ll(x, ages::AbstractVector{<:Radiocarbon}) = interpolate_ll(x, ages)
439+
strat_ll(x, ages::AbstractVector{<:Normal}) = normpdf_ll(x, ages)
440+
function strat_ll(x, ages::AbstractVector)
441+
ll = zero(float(eltype(x)))
442+
@inbounds for i in eachindex(x,ages)
443+
ll += logpdf(ages[i], x[i])
444+
end
445+
return ll
446+
end
440447

441-
adjust!(ages::AbstractVector, chronometer, systematic::Nothing) = (return ages)
448+
adjust!(ages::AbstractVector, chronometer, systematic::Nothing) = ages
442449
function adjust!(ages::AbstractVector{BilinearExponential{T}}, chronometer, systematic::SystematicUncertainty) where T
443450
systUPb = randn()*systematic.UPb
444451
systArAr = randn()*systematic.ArAr
@@ -448,20 +455,20 @@
448455
μ = age.μ
449456
chronometer[i] === :UPb &&+= systUPb)
450457
chronometer[i] === :ArAr &&+= systArAr)
451-
ages[i] = BilinearExponential{T}(age.A, μ, age.σ, age.sharpness, age.skew)
458+
ages[i] = BilinearExponential{T}(age.A, μ, age.σ, age.shp, age.skw)
452459
end
453460
return ages
454461
end
455-
function adjust!(ages::AbstractVector{Normal{T}}, chronometer, systematic::SystematicUncertainty) where T
462+
function adjust!(ages::AbstractVector, chronometer, systematic::SystematicUncertainty) where T
456463
systUPb = randn()*systematic.UPb
457464
systArAr = randn()*systematic.ArAr
458465
@assert eachindex(ages)==eachindex(chronometer)
459466
@inbounds for i eachindex(ages)
460-
age = ages[i]
461-
μ = age.μ
462-
chronometer[i] === :UPb &&+= systUPb)
463-
chronometer[i] === :ArAr && += systArAr)
464-
ages[i] = Normal{T}(μ, age.σ)
467+
if chronometer[i] === :UPb
468+
ages[i] += systUPb
469+
elseif chronometer[i] === :ArAr
470+
ages[i] += systArAr
471+
end
465472
end
466473
return ages
467474
end

0 commit comments

Comments
 (0)