Beispiel #1
0
void Discriminant_getPartialDiscriminationProbability (Discriminant me, long numberOfDimensions, double *p_prob, double *p_chisq, double *p_df)
{
    long g = my numberOfGroups;
    long p = my eigen -> dimension, k = numberOfDimensions;
    long numberOfFunctions = Discriminant_getNumberOfFunctions (me);
    double degreesOfFreedom = Discriminant_getDegreesOfFreedom (me);

    double prob = NUMundefined,  chisq = NUMundefined, df = NUMundefined;

    if (k < numberOfFunctions) {
        double lambda = NUMwilksLambda (my eigen -> eigenvalues, k + 1, numberOfFunctions);
        if (lambda != 1.0) {
            chisq = - (degreesOfFreedom + (g - p) / 2.0 - 1.0) * log (lambda);
            df = (p - k) * (g - k - 1);
            if (p_prob) {
                prob =  NUMchiSquareQ (chisq, df);
            }
        }
    }
    if (p_prob) {
        *p_prob = prob;
    }
    if (p_chisq) {
        *p_chisq = chisq;
    }
    if (p_df) {
        *p_df = df;
    }
}
Beispiel #2
0
void Discriminant_getPartialDiscriminationProbability (Discriminant me,
        long numberOfDimensions, double *probability, double *chisq, long *ndf) {
	long g = my numberOfGroups;
	long p = my dimension, k = numberOfDimensions;
	long numberOfFunctions = Discriminant_getNumberOfFunctions (me);
	double degreesOfFreedom = Discriminant_getDegreesOfFreedom (me);
	double lambda;

	*probability = 1; *chisq = 0; *ndf = 0;

	if (k >= numberOfFunctions) {
		return;
	}

	lambda = NUMwilksLambda (my eigenvalues, k + 1, numberOfFunctions);

	if (lambda == 1) {
		return;
	}

	*chisq = - (degreesOfFreedom + (g - p) / 2 - 1) * log (lambda);
	*ndf = (p - k) * (g - k - 1);
	*probability =  NUMchiSquareQ (*chisq, *ndf);
}