code: public static double assignProbabilitiesToInstances(Relation<? extends NumberVector> relation, List<? extends EMClusterModel<?>> models, WritableDataStore<double[]> probClusterIGivenX) {
      final int k = models.size();
      double emSum = 0.;
  
      for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
        NumberVector vec = relation.get(iditer);
        double[] probs = new double[k];
        for(int i = 0; i < k; i++) {
          double v = models.get(i).estimateLogDensity(vec);
          probs[i] = v > MIN_LOGLIKELIHOOD ? v : MIN_LOGLIKELIHOOD;
        }
        final double logP = logSumExp(probs);
        for(int i = 0; i < k; i++) {
          probs[i] = FastMath.exp(probs[i] - logP);
        }
        probClusterIGivenX.put(iditer, probs);
        emSum += logP;
      }
      return emSum / relation.size();
    }
docs: Assigns the current probability values to the instances in the database and
  compute the expectation value of the current mixture of distributions.
  
  Computed as the sum of the logarithms of the prior probability of each
  instance.
  
  @param relation the database used for assignment to instances
  @param models Cluster models
  @param probClusterIGivenX Output storage for cluster probabilities
  @return the expectation value of the current mixture of distributions