private void assignUnassigned(Relation<V> relation,WritableDataStore<double[]> probClusterIGivenX,List<MultivariateGaussianModel> models,ModifiableDBIDs unassigned){
  if (unassigned.size() == 0) {
    return;
  }
  final int k=models.size();
  double pweight=1. / relation.size();
  for (  EMClusterModel<?> m : models) {
    m.setWeight(m.getWeight() * (relation.size() - unassigned.size()) * pweight);
  }
  for (DBIDIter iter=unassigned.iter(); iter.valid(); iter.advance()) {
    V v=relation.get(iter);
    int bestCluster=-1;
    MultivariateGaussianModel bestModel=null;
    double minDistance=Double.POSITIVE_INFINITY;
    int c=0;
    for (    MultivariateGaussianModel model : models) {
      final double distance=model.mahalanobisDistance(v);
      if (distance < minDistance) {
        minDistance=distance;
        bestCluster=c;
        bestModel=model;
      }
      c++;
    }
    double[] weights=new double[k];
    weights[bestCluster]=1.;
    bestModel.setWeight(bestModel.getWeight() + pweight);
    probClusterIGivenX.put(iter,weights);
  }
  unassigned.clear();
}

private void assignUnassigned ( Relation < V > relation , WritableDataStore < double [ ] > probClusterIGivenX , List < MultivariateGaussianModel > models , ModifiableDBIDs unassigned ) { if ( unassigned . size ( ) == 0 ) { return ; } final int k = models . size ( ) ; double pweight = 1. / relation . size ( ) ; for ( EMClusterModel < ? > m : models ) { m . setWeight ( m . getWeight ( ) * ( relation . size ( ) - unassigned . size ( ) ) * pweight ) ; } for ( DBIDIter iter = unassigned . iter ( ) ; iter . valid ( ) ; iter . advance ( ) ) { V v = relation . get ( iter ) ; int bestCluster = - 1 ; MultivariateGaussianModel bestModel = null ; double minDistance = Double . POSITIVE_INFINITY ; int c = 0 ; for ( MultivariateGaussianModel model : models ) { final double distance = model . mahalanobisDistance ( v ) ; if ( distance < minDistance ) { minDistance = distance ; bestCluster = c ; bestModel = model ; } c ++ ; } double [ ] weights = new double [ k ] ; weights [ bestCluster ] = 1. ; bestModel . setWeight ( bestModel . getWeight ( ) + pweight ) ; probClusterIGivenX . put ( iter , weights ) ; } unassigned . clear ( ) ; }
assign unassigned objects to best candidate based on shortest mahalanobis distance .
