void GaussianMixture_and_PCA_drawConcentrationEllipses (GaussianMixture me, PCA him, Graphics g, double scale, int confidence, wchar_t *label, long d1, long d2, double xmin, double xmax, double ymin, double ymax, int fontSize, int garnish) { if (my dimension != his dimension) { Melder_warning1 (L"Dimensions don't agree."); return;} SSCPs thee = NULL; int d1_inverted = 0, d2_inverted = 0; if (d1 < 0) { d1 = abs(d1); Eigen_invertEigenvector (him, d1); d1_inverted = 1; } if (d2 < 0) { d2 = abs(d2); Eigen_invertEigenvector (him, d2); d2_inverted = 1; } if ((thee = SSCPs_toTwoDimensions ((SSCPs) my covariances, his eigenvectors[d1], his eigenvectors[d2])) == NULL) goto end; if (d1_inverted) Eigen_invertEigenvector (him, d1); if (d2_inverted) Eigen_invertEigenvector (him, d2); SSCPs_drawConcentrationEllipses (thee, g, -scale, confidence, label, 1, 2, xmin, xmax, ymin, ymax, fontSize, 0); if (garnish) { wchar_t label[40]; Graphics_drawInnerBox (g); Graphics_marksLeft (g, 2, 1, 1, 0); swprintf (label, 40, L"pc %ld", d2); Graphics_textLeft (g, 1, label); Graphics_marksBottom (g, 2, 1, 1, 0); swprintf (label, 40, L"pc %ld", d1); Graphics_textBottom (g, 1, label); } end: forget (thee); }
void Discriminant_drawConcentrationEllipses (Discriminant me, Graphics g, double scale, int confidence, char32 *label, int discriminantDirections, long d1, long d2, double xmin, double xmax, double ymin, double ymax, int fontSize, int garnish) { long numberOfFunctions = Discriminant_getNumberOfFunctions (me); if (! discriminantDirections) { SSCPs_drawConcentrationEllipses (my groups, g, scale, confidence, label, d1, d2, xmin, xmax, ymin, ymax, fontSize, garnish); return; } if (numberOfFunctions <= 1) { Melder_warning (U"Discriminant_drawConcentrationEllipses: Nothing drawn " U"because there is only one dimension in the discriminant space."); return; } // Project SSCPs on eigenvectors. if (d1 == 0 && d2 == 0) { d1 = 1; d2 = MIN (numberOfFunctions, d1 + 1); } else if (d1 < 0 || d2 > numberOfFunctions) { return; } double *v1 = my eigenvectors[d1]; double *v2 = my eigenvectors[d2]; autoSSCPs thee = SSCPs_toTwoDimensions (my groups, v1, v2); SSCPs_drawConcentrationEllipses (thee.peek(), g, scale, confidence, label, 1, 2, xmin, xmax, ymin, ymax, fontSize, 0); if (garnish) { char32 llabel[40]; Graphics_drawInnerBox (g); Graphics_marksLeft (g, 2, 1, 1, 0); Melder_sprint (llabel,40, U"function ", d2); Graphics_textLeft (g, 1, llabel); Graphics_marksBottom (g, 2, 1, 1, 0); Melder_sprint (llabel,40, U"function ", d1); Graphics_textBottom (g, 1, llabel); } }