+ //deltaValues[0] = scores for the difference between AA and AB.
+ //cValues[0][0][0] = AA at distance 0.0, cValues[0][0][1] = AB at distance 0.0, cValues[0][0][2] = AC at distance 0.0, cValues[0][1][0] = BA at distance 0.0, cValues[0][1][1] = BB...
+ Progress* reading;
+ reading = new Progress("Comparing to random:", iters);
+
+ sumDelta.resize(numComp-numGroups, 0.0);
+
+ matrix->setBounds();
+
+ //load distances
+ if (form != "discrete") { matrix->getDist(dist); }
+ else {
+ float f = 0.0;
+ while (f <= cutOff) {
+ dist.push_back(f);
+ f += step;
+ }
+ }
+
+ /*****************************/
+ //get values for users matrix
+ /*****************************/
+
+ //clear out old Values
+ deltaValues.clear();
+ deltaValues.resize(dist.size());
+
+ coverage->getValues(matrix, cValues, dist, "user");
+
+ //loop through each distance and load rsumdelta
+ for (int p = 0; p < cValues.size(); p++) {
+ //find delta values
+ int count = 0;
+ for (int i = 0; i < numGroups; i++) {
+ for (int j = 0; j < numGroups; j++) {
+ //don't save AA to AA
+ if (i != j) {
+ //(Caa - Cab)^2
+ deltaValues[p].push_back((cValues[p][i][i]-cValues[p][i][j]) * (cValues[p][i][i]-cValues[p][i][j]));
+ sumDelta[count] += deltaValues[p][count];
+ count++;
+ }
+ }
+ }
+ }
+
+ printCoverageFile();
+
+ /*******************************************************************************/
+ //create and score random matrixes finding the sumDelta values for summary file
+ /******************************************************************************/
+
+ //initialize rsumDelta
+ rsumDelta.resize(numComp-numGroups);
+ for (int l = 0; l < rsumDelta.size(); l++) {
+ for (int w = 0; w < iters; w++) {
+ rsumDelta[l].push_back(0.0);
+ }
+ }
+
+
+ for (int m = 0; m < iters; m++) {
+ //generate random matrix in getValues
+ //values for random matrix
+
+ coverage->getValues(matrix, cValues, dist, "random");
+
+ //loop through each distance and load rsumdelta
+ for (int p = 0; p < cValues.size(); p++) {
+ //find delta values
+ int count = 0;
+ for (int i = 0; i < numGroups; i++) {
+ for (int j = 0; j < numGroups; j++) {
+ //don't save AA to AA
+ if (i != j) {
+ //(Caa - Cab)^2
+ rsumDelta[count][m] += ((cValues[p][i][i]-cValues[p][i][j]) * (cValues[p][i][i]-cValues[p][i][j]));
+ count++;
+ }
+ }
+ }
+
+ }
+
+ //clear out old Values
+ reading->update(m);
+ cValues.clear();
+
+ }
+
+ reading->finish();
+ delete reading;
+
+ /**********************************************************/
+ //find the signifigance of the user matrix' sumdelta values
+ /**********************************************************/
+
+ for (int t = 0; t < rsumDelta.size(); t++) {
+ //sort rsumDelta t
+ sort(rsumDelta[t].begin(), rsumDelta[t].end());
+
+ //the index of the score higher than yours is returned
+ //so if you have 1000 random matrices the index returned is 100
+ //then there are 900 matrices with a score greater then you.
+ //giving you a signifigance of 0.900
+ int index = findIndex(sumDelta[t], t);
+
+ //the signifigance is the number of trees with the users score or higher
+ sumDeltaSig.push_back((iters-index)/(float)iters);
+
+ }
+
+ printSummaryFile();
+
+ //clear out users groups
+ globaldata->Groups.clear();
+