File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
mllib/src/main/scala/org/apache/spark/mllib/stat/impl Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ class MultivariateGaussian private[mllib] (
5959 * u = log((2*pi)^(-k/2)^ * det(sigma)^(-1/2)^)
6060 */
6161 private val (rootSigmaInv : DBM [Double ], u : Double ) = calculateCovarianceConstants
62-
62+
6363 /** Return the mean vector (mu) for this distribution */
6464 def getMu : Vector = Vectors .fromBreeze(mu)
6565
@@ -124,14 +124,14 @@ class MultivariateGaussian private[mllib] (
124124 val tol = MLUtils .EPSILON * max(d) * d.length
125125
126126 try {
127- // pseudo-determinant is product of all non-zero singular values
127+ // log( pseudo-determinant) is sum of the logs of all non-zero singular values
128128 val logPseudoDetSigma = d.activeValuesIterator.filter(_ > tol).map(math.log(_)).reduce(_ + _)
129129
130130 // calculate the root-pseudo-inverse of the diagonal matrix of singular values
131131 // by inverting the square root of all non-zero values
132132 val pinvS = diag(new DBV (d.map(v => if (v > tol) math.sqrt(1.0 / v) else 0.0 ).toArray))
133133
134- (pinvS * u, ( - mu.length / 2.0 ) * math.log(2.0 * math.Pi ) + - 0.5 * logPseudoDetSigma)
134+ (pinvS * u, - 0.5 * (mu.length * math.log(2.0 * math.Pi ) + logPseudoDetSigma) )
135135 } catch {
136136 case uex : UnsupportedOperationException =>
137137 throw new IllegalArgumentException (" Covariance matrix has no non-zero singular values" )
You can’t perform that action at this time.
0 commit comments