double BayesianClassifier::g(const math::matrix<double> & x, const Distribution & distribution)
{
    //          1        T  -1
    // gi(x) = --(x - mi) Ei  (x - mi) + Ln P(wi) + ci
    //          2

    //ci = -(1/2)Ln 2PI - (1/2) Ln |Ei|

    double distance, lp, ci;

    distance = -0.5*calculate_mahalanobis_distance(x, distribution);

    lp = log(distribution.parameters.get_a_priori_probability());

    ci = -0.5*(log(2*M_PI) + log(distribution.info.E.Det()));

    return distance + lp + ci;
}
float calculate_mahalanobis_distance_ratio(EXAMPLEDATA* data, MAHALANOBISDISTANCERATIOCLASSIFIER* mdr_classifier)
{
	float d0 = calculate_mahalanobis_distance(data, mdr_classifier->num_feature, mdr_classifier->param[0]);
	float d1 = calculate_mahalanobis_distance(data, mdr_classifier->num_feature, mdr_classifier->param[1]);
	return d0/d1;
}