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 85a66306 authored by Dahua Lin's avatar Dahua Lin

add AbstractMixtureModel

parent 3ba70db1
......@@ -39,6 +39,7 @@ export
ContinuousMatrixDistribution,
SufficientStats,
AbstractMvNormal,
AbstractMixtureModel,
UnivariateMixture,
MultivariateMixture,
......
# finite mixture models
immutable MixtureModel{VF<:VariateForm, VS<:ValueSupport, Component<:Distribution} <: Distribution{VF,VS}
abstract AbstractMixtureModel{VF<:VariateForm,VS<:ValueSupport} <: Distribution{VF, VS}
immutable MixtureModel{VF<:VariateForm,VS<:ValueSupport,Component<:Distribution} <: AbstractMixtureModel{VF,VS}
components::Vector{Component}
prior::Categorical
end
typealias UnivariateMixture MixtureModel{Univariate}
typealias MultivariateMixture MixtureModel{Multivariate}
typealias MatrixvariateMixture MixtureModel{Matrixvariate}
typealias UnivariateMixture AbstractMixtureModel{Univariate}
typealias MultivariateMixture AbstractMixtureModel{Multivariate}
typealias MatrixvariateMixture AbstractMixtureModel{Matrixvariate}
#### Constructors
......
......@@ -107,11 +107,9 @@ end
println(" testing UnivariateMixture")
g_u = MixtureModel(
Normal[Normal(0.0, 1.0), Normal(2.0, 1.0), Normal(-4.0, 1.5)],
[0.2, 0.5, 0.3])
g_u = MixtureModel(Normal, [(0.0, 1.0), (2.0, 1.0), (-4.0, 1.5)], [0.2, 0.5, 0.3])
@test isa(g_u, MixtureModel{Univariate, Continuous, Normal})
@test length(components(g_u)) == 3
test_mixture(g_u, 1000, 10^6)
......@@ -121,8 +119,8 @@ g_m = MixtureModel(
MvNormal([0.2, 1.0], 1.0),
MvNormal([-0.5, -3.0], 1.6) ],
[0.2, 0.5, 0.3])
@test isa(g_m, MixtureModel{Multivariate, Continuous, IsoNormal})
@test length(components(g_m)) == 3
@test length(g_m) == 2
test_mixture(g_m, 1000, 10^6)
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