Skip to content

Commit

Permalink
Added ConstantDistribution struct
Browse files Browse the repository at this point in the history
  • Loading branch information
arzwa committed Jan 15, 2020
1 parent 77ecf8f commit ebf3323
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/mcmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ Base.getindex(x::State, s::Symbol, i::Int64) = x[s][i]
# HACK: for constant parameters
Distributions.logpdf(d::Float64, x::Float64) = 0.

"""
ConstantDistribution(x)
A 'constant' distribution (Dirac mass), sometimes useful.
"""
struct ConstantDistribution{T}
x::T
end

Base.rand(x::ConstantDistribution) = x.x
pdf(x::ConstantDistribution, y) = y x.x ? 1. : 0.
logpdf(x::ConstantDistribution, y) = log(pdf(x, y))


# GBM model
"""
GBMModel(st::SlicedTree, ν::T, η::T, λ::T, μ::T, q::T) where
Expand Down

0 comments on commit ebf3323

Please sign in to comment.