public static void recomputeCovarianceMatrices(Relation<? extends NumberVector> relation,WritableDataStore<double[]> probClusterIGivenX,List<? extends EMClusterModel<?>> models){
  for (  EMClusterModel<?> m : models) {
    m.beginEStep();
  }
  double[] wsum=new double[models.size()];
  for (DBIDIter iditer=relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
    double[] clusterProbabilities=probClusterIGivenX.get(iditer);
    NumberVector instance=relation.get(iditer);
    int i=0;
    for (    EMClusterModel<?> m : models) {
      final double prior=clusterProbabilities[i];
      if (prior > 0.) {
        m.updateE(instance,prior);
      }
      wsum[i]+=prior;
      ++i;
    }
  }
  int i=0;
  for (  EMClusterModel<?> m : models) {
    m.finalizeEStep();
    m.setWeight(wsum[i] / relation.size());
    i++;
  }
}

public static void recomputeCovarianceMatrices ( Relation < ? extends NumberVector > relation , WritableDataStore < double [ ] > probClusterIGivenX , List < ? extends EMClusterModel < ? > > models ) { for ( EMClusterModel < ? > m : models ) { m . beginEStep ( ) ; } double [ ] wsum = new double [ models . size ( ) ] ; for ( DBIDIter iditer = relation . iterDBIDs ( ) ; iditer . valid ( ) ; iditer . advance ( ) ) { double [ ] clusterProbabilities = probClusterIGivenX . get ( iditer ) ; NumberVector instance = relation . get ( iditer ) ; int i = 0 ; for ( EMClusterModel < ? > m : models ) { final double prior = clusterProbabilities [ i ] ; if ( prior > 0. ) { m . updateE ( instance , prior ) ; } wsum [ i ] += prior ; ++ i ; } } int i = 0 ; for ( EMClusterModel < ? > m : models ) { m . finalizeEStep ( ) ; m . setWeight ( wsum [ i ] / relation . size ( ) ) ; i ++ ; } }
recompute the covariance matrixes .
