/** * Returns the logs of the joint densities for a given instance. * * @param inst the instance * @return the array of values * @exception Exception if values could not be computed */ public double[] logJointDensitiesForInstance(Instance inst) throws Exception { double[] weights = logDensityPerClusterForInstance(inst); double[] priors = clusterPriors(); for (int i = 0; i < weights.length; i++) { if (priors[i] > 0) { weights[i] += Math.log(priors[i]); } else { throw new IllegalArgumentException("Cluster empty!"); } } return weights; }
/** * Returns the logs of the joint densities for a given instance. * * @param inst the instance * @return the array of values * @exception Exception if values could not be computed */ public double[] logJointDensitiesForInstance(Instance inst) throws Exception { double[] weights = logDensityPerClusterForInstance(inst); double[] priors = clusterPriors(); for (int i = 0; i < weights.length; i++) { if (priors[i] > 0) { weights[i] += Math.log(priors[i]); } else { throw new IllegalArgumentException("Cluster empty!"); } } return weights; }