protected void maximization ( ) { // discard previous parameters by zeroing for ( int i = 0 ; i < mixture . size ; i ++ ) { mixture . get ( i ) . zero ( ) ; } // compute the new mean for ( int i = 0 ; i < info . size ; i ++ ) { PointInfo p = info . get ( i ) ; for ( int j = 0 ; j < mixture . size ; j ++ ) { mixture . get ( j ) . addMean ( p . point , p . weights . get ( j ) ) ; } } for ( int i = 0 ; i < mixture . size ; i ++ ) { GaussianGmm_F64 g = mixture . get ( i ) ; if ( g . weight > 0 ) CommonOps_DDRM . divide ( g . mean , g . weight ) ; } // compute new covariance for ( int i = 0 ; i < info . size ; i ++ ) { PointInfo pp = info . get ( i ) ; double [ ] p = pp . point ; for ( int j = 0 ; j < mixture . size ; j ++ ) { GaussianGmm_F64 g = mixture . get ( j ) ; for ( int k = 0 ; k < p . length ; k ++ ) { dx [ k ] = p [ k ] - g . mean . data [ k ] ; } mixture . get ( j ) . addCovariance ( dx , pp . weights . get ( j ) ) ; } } double totalMixtureWeight = 0 ; for ( int i = 0 ; i < mixture . size ; i ++ ) { GaussianGmm_F64 g = mixture . get ( i ) ; if ( g . weight > 0 ) { CommonOps_DDRM . divide ( g . covariance , g . weight ) ; totalMixtureWeight += g . weight ; } } // update the weight for ( int i = 0 ; i < mixture . size ; i ++ ) { mixture . get ( i ) . weight /= totalMixtureWeight ; } }
Using points responsibility information to recompute the Gaussians and their weights maximizing the likelihood of the mixture .