/** * Computes log of density for given value. */ public double logDensity(double value) { double[] a = logJointDensities(value); double max = a[Utils.maxIndex(a)]; double sum = 0.0; for(int i = 0; i < a.length; i++) { sum += Math.exp(a[i] - max); } return max + Math.log(sum); }
/** * Computes log of density for given value. */ public double logDensity(double value) { double[] a = logJointDensities(value); double max = a[Utils.maxIndex(a)]; double sum = 0.0; for(int i = 0; i < a.length; i++) { sum += Math.exp(a[i] - max); } return max + Math.log(sum); }
double[] p = Utils.logs2probs(model.logJointDensities(values[i])); for (int j = 0; j < p.length; j++) { probs[j][i] = p[j];
double[] p = Utils.logs2probs(model.logJointDensities(values[i])); for (int j = 0; j < p.length; j++) { probs[j][i] = p[j];
/** * Calculates entrpy for given model and data. */ protected double entropy(MM mixtureModel) { double entropy = 0; for (int j = 0; j < m_NumValues; j++) { entropy += m_Weights[j] * ContingencyTables.entropy(Utils.logs2probs(mixtureModel.logJointDensities(m_Values[j]))); } entropy *= Utils.log2; // Need natural logarithm, not base-2 logarithm return entropy / (double)m_NumValues; }
/** * Calculates entrpy for given model and data. */ protected double entropy(MM mixtureModel) { double entropy = 0; for (int j = 0; j < m_NumValues; j++) { entropy += m_Weights[j] * ContingencyTables.entropy(Utils.logs2probs(mixtureModel.logJointDensities(m_Values[j]))); } entropy *= Utils.log2; // Need natural logarithm, not base-2 logarithm return entropy / (double)m_NumValues; }