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 7673e985 authored by Dahua Lin's avatar Dahua Lin

introduce probs method

parent 85a66306
......@@ -199,7 +199,7 @@ export
ncategories, # the number of categories in a Categorical distribution
pdf, # probability density function (ContinuousDistribution)
pmf, # probability mass function (DiscreteDistribution)
priorprobs, # prior probabilities
probs, # Get the vector of probabilities
quantile, # inverse of cdf (defined for p in (0,1))
qqbuild, # build a paired quantiles data structure for qqplots
sampler, # create a Sampler object for efficient samples
......
......@@ -49,13 +49,13 @@ length(d::MultivariateMixture) = length(d.components[1])
size(d::MatrixvariateMixture) = size(d.components[1])
components(d::MixtureModel) = d.components
priorprobs(d::MixtureModel) = d.prior.prob
probs(d::MixtureModel) = d.prior.prob
component_type{VF,VS,C}(d::MixtureModel{VF,VS,C}) = C
function mean(d::UnivariateMixture)
cs = components(d)
p = priorprobs(d)
p = probs(d)
m = 0.0
for i = 1:length(cs)
pi = p[i]
......@@ -68,7 +68,7 @@ end
function mean(d::MultivariateMixture)
cs = components(d)
p = priorprobs(d)
p = probs(d)
m = zeros(length(d))
for i = 1:length(cs)
pi = p[i]
......@@ -81,7 +81,7 @@ end
function var(d::UnivariateMixture)
cs = components(d)
p = priorprobs(d)
p = probs(d)
K = length(cs)
means = Array(Float64, K)
m = 0.0
......@@ -109,7 +109,7 @@ end
function show(io::IO, d::MixtureModel)
cs = components(d)
pr = priorprobs(d)
pr = probs(d)
K = length(cs)
println(io, "MixtureModel{$(component_type(d))}(K = $K)")
Ks = min(K, 8)
......@@ -128,7 +128,7 @@ end
function _mixpdf1(d::MixtureModel, x)
cs = components(d)
p = priorprobs(d)
p = probs(d)
v = 0.0
for i = 1:length(cs)
pi = p[i]
......@@ -141,7 +141,7 @@ end
function _mixpdf!(r::DenseArray, d::MixtureModel, x)
cs = components(d)
p = priorprobs(d)
p = probs(d)
fill!(r, 0.0)
t = Array(Float64, size(r))
for i = 1:length(cs)
......@@ -170,7 +170,7 @@ function _mixlogpdf1(d::MixtureModel, x)
#
cs = components(d)
p = priorprobs(d)
p = probs(d)
K = length(cs)
lp = Array(Float64, K)
m = -Inf # m <- the maximum of log(p(cs[i], x)) + log(pri[i])
......@@ -195,7 +195,7 @@ end
function _mixlogpdf!(r::DenseArray, d::MixtureModel, x)
cs = components(d)
p = priorprobs(d)
p = probs(d)
K = length(cs)
n = length(r)
Lp = Array(Float64, n, K)
......
......@@ -20,6 +20,8 @@ end
length(d::Multinomial) = length(d.prob)
probs(d::Multinomial) = d.prob
mean(d::Multinomial) = d.n .* d.prob
function var(d::Multinomial)
......
......@@ -13,6 +13,7 @@ immutable Categorical <: DiscreteUnivariateDistribution
end
ncategories(d::Categorical) = d.K
probs(d::Categorical) = d.prob
### handling support
......
......@@ -10,7 +10,7 @@ function test_mixture(g::UnivariateMixture, n::Int, ns::Int)
end
cs = components(g)
pr = priorprobs(g)
pr = probs(g)
@assert length(cs) == length(pr)
# mean
......@@ -59,7 +59,7 @@ function test_mixture(g::MultivariateMixture, n::Int, ns::Int)
end
cs = components(g)
pr = priorprobs(g)
pr = probs(g)
@assert length(cs) == length(pr)
# mean
......
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