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; } }
double Discriminant_getWilksLambda (Discriminant me, long from) { long numberOfFunctions = Discriminant_getNumberOfFunctions (me); if (from >= numberOfFunctions) { return 1; } if (from < 1) { from = 1; } return NUMwilksLambda (my eigen -> eigenvalues, 1 + from, numberOfFunctions); }
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); }