|
434 | 434 | ## --- # Internals of the Markov chain
|
435 | 435 |
|
436 | 436 | # 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 |
440 | 447 |
|
441 |
| - adjust!(ages::AbstractVector, chronometer, systematic::Nothing) = (return ages) |
| 448 | + adjust!(ages::AbstractVector, chronometer, systematic::Nothing) = ages |
442 | 449 | function adjust!(ages::AbstractVector{BilinearExponential{T}}, chronometer, systematic::SystematicUncertainty) where T
|
443 | 450 | systUPb = randn()*systematic.UPb
|
444 | 451 | systArAr = randn()*systematic.ArAr
|
|
448 | 455 | μ = age.μ
|
449 | 456 | chronometer[i] === :UPb && (μ += systUPb)
|
450 | 457 | 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) |
452 | 459 | end
|
453 | 460 | return ages
|
454 | 461 | end
|
455 |
| - function adjust!(ages::AbstractVector{Normal{T}}, chronometer, systematic::SystematicUncertainty) where T |
| 462 | + function adjust!(ages::AbstractVector, chronometer, systematic::SystematicUncertainty) where T |
456 | 463 | systUPb = randn()*systematic.UPb
|
457 | 464 | systArAr = randn()*systematic.ArAr
|
458 | 465 | @assert eachindex(ages)==eachindex(chronometer)
|
459 | 466 | @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 |
465 | 472 | end
|
466 | 473 | return ages
|
467 | 474 | end
|
|
0 commit comments