Skip to content

Commit

Permalink
Fix #15
Browse files Browse the repository at this point in the history
workaround to create Multivarite normal distributions from inpositive
definite covariance matrix
  • Loading branch information
r9y9 committed Oct 19, 2016
1 parent 29e8334 commit 8acd2ba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ Compat
HDF5 0.4.0
JLD
StatsBase
StatsFuns
Distributions 0.6.2
MelGeneralizedCepstrums 0.0.3
1 change: 1 addition & 0 deletions src/VoiceConversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module VoiceConversion

using StatsBase
using StatsFuns
using Distributions
using MelGeneralizedCepstrums
using HDF5, JLD
Expand Down
9 changes: 7 additions & 2 deletions src/gmm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
typealias GMM{Cov,Mean} MixtureModel{Multivariate,Continuous,MvNormal{Cov,Mean}}

# proxy to MixtureModel{Multivariate,Continuous,MvNormal{Cov, Mean}}
function GaussianMixtureModel(means, covars, weights)
function GaussianMixtureModel(means, covars, weights; forcepd::Bool=true)
n_components = size(means, 2)
normals = Array(MvNormal, n_components)
for m=1:n_components
normals[m] = MvNormal(means[:,m], covars[:,:,m])
# force covariance matrix to be positive definite to avoid error on
# creating PDMat internally
# TODO: is this really correct?
# caused by https://github.com/JuliaLang/julia/pull/16799
covar = forcepd ? Array(Hermitian(covars[:,:,m])) : covars[:,:,m]
normals[m] = MvNormal(means[:,m], covar)
end
MixtureModel(normals, weights)
end
Expand Down

0 comments on commit 8acd2ba

Please sign in to comment.