Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

Commit 39dea986 authored by Dahua Lin's avatar Dahua Lin

Introduce IncompleteDistribution (in the place of GenerativeFormulation) and...

Introduce IncompleteDistribution (in the place of GenerativeFormulation) and IncompleteFormulation to simplify generic codes
parent 3aa124fc
......@@ -187,7 +187,10 @@ typealias DiscreteMatrixDistribution Distribution{Matrixvariate, Discret
typealias ContinuousMatrixDistribution Distribution{Matrixvariate, Continuous}
abstract SufficientStats
abstract GenerativeFormulation
abstract IncompleteDistribution
typealias DistributionType{D<:Distribution} Type{D}
typealias IncompleteFormulation Union(DistributionType,IncompleteDistribution)
#### Include files
......
# Fallback functions for conjugates
posterior{D<:Distribution}(pri::Distribution, G::Type{D}, x) = posterior(pri, suffstats(G, x))
posterior(pri::Distribution, G::GenerativeFormulation, x) = posterior(pri, suffstats(G, x))
posterior{D<:Distribution}(pri::Distribution, G::Type{D}, x, w) = posterior(pri, suffstats(G, x, w))
posterior(pri::Distribution, G::GenerativeFormulation, x, w) = posterior(pri, suffstats(G, x, w))
posterior(pri::Distribution, G::IncompleteFormulation, x) = posterior(pri, suffstats(G, x))
posterior(pri::Distribution, G::IncompleteFormulation, x, w) = posterior(pri, suffstats(G, x, w))
posterior_rand(pri::Distribution, s::SufficientStats) = rand(posterior(pri, s))
posterior_rand{D<:Distribution}(pri::Distribution, G::Type{D}, x) = rand(posterior(pri, G, x))
posterior_rand{D<:Distribution}(pri::Distribution, G::Type{D}, x, w) = rand(posterior(pri, G, x, w))
posterior_rand(pri::Distribution, G::GenerativeFormulation, x) = rand(posterior(pri, G, x))
posterior_rand(pri::Distribution, G::GenerativeFormulation, x, w) = rand(posterior(pri, G, x, w))
posterior_rand(pri::Distribution, G::IncompleteFormulation, x) = rand(posterior(pri, G, x))
posterior_rand(pri::Distribution, G::IncompleteFormulation, x, w) = rand(posterior(pri, G, x, w))
posterior_rand!(r::Array, pri::Distribution, s::SufficientStats) = rand!(posterior(pri, s), r)
posterior_rand!{D<:Distribution}(r::Array, pri::Distribution, G::Type{D}, x) = rand!(posterior(pri, G, x), r)
posterior_rand!{D<:Distribution}(r::Array, pri::Distribution, G::Type{D}, x, w) = rand!(posterior(pri, G, x, w), r)
posterior_rand!(r::Array, pri::Distribution, G::GenerativeFormulation, x) = rand!(posterior(pri, G, x), r)
posterior_rand!(r::Array, pri::Distribution, G::GenerativeFormulation, x, w) = rand!(posterior(pri, G, x, w), r)
posterior_rand!(r::Array, pri::Distribution, G::IncompleteFormulation, x) = rand!(posterior(pri, G, x), r)
posterior_rand!(r::Array, pri::Distribution, G::IncompleteFormulation, x, w) = rand!(posterior(pri, G, x, w), r)
posterior_mode(pri::Distribution, s::SufficientStats) = mode(posterior(pri, s))
posterior_mode{D<:Distribution}(pri::Distribution, G::Type{D}, x) = mode(posterior(pri, G, x))
posterior_mode{D<:Distribution}(pri::Distribution, G::Type{D}, x, w) = mode(posterior(pri, G, x, w))
posterior_mode(pri::Distribution, G::GenerativeFormulation, x) = mode(posterior(pri, G, x))
posterior_mode(pri::Distribution, G::GenerativeFormulation, x, w) = mode(posterior(pri, G, x, w))
posterior_mode(pri::Distribution, G::IncompleteFormulation, x) = mode(posterior(pri, G, x))
posterior_mode(pri::Distribution, G::IncompleteFormulation, x, w) = mode(posterior(pri, G, x, w))
posterior_make{D<:Distribution}(::Type{D}, θ) = D(θ)
fit_map{D<:Distribution}(pri::Distribution, ::Type{D}, x) = posterior_make(D, posterior_mode(pri, D, x))
......
......@@ -7,7 +7,7 @@
# on (co)variance.
#
immutable MvNormalKnownSigma <: GenerativeFormulation
immutable MvNormalKnownSigma <: IncompleteDistribution
Sigma::Matrix{Float64}
function MvNormalKnownSigma(S::Matrix{Float64})
......
......@@ -108,7 +108,7 @@ end
# Cases where μ or σ is known
immutable NormalKnownMu <: GenerativeFormulation
immutable NormalKnownMu <: IncompleteDistribution
μ::Float64
end
......@@ -140,7 +140,7 @@ function suffstats{T<:Real}(g::NormalKnownMu, x::Array{T}, w::Array{Float64})
end
immutable NormalKnownSigma <: GenerativeFormulation
immutable NormalKnownSigma <: IncompleteDistribution
σ::Float64
function NormalKnownSigma(σ::Float64)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment