]> git.donarmstrong.com Git - mothur.git/blobdiff - trialSwap2.cpp
forced rarefaction.single to output ending line for all groups. added subsample...
[mothur.git] / trialSwap2.cpp
index 2d25e835cbd5608bc1c4f4c6cc67397155f2c834..71c3027db2c8bbe97265cb40af839c6a81a17b33 100644 (file)
@@ -291,6 +291,34 @@ double TrialSwap2::t_test (double initialscore, int runs, double nullMean, vecto
     }
 }
 /**************************************************************************************************/
+double TrialSwap2::getSD (int runs, vector<double> scorevec, double nullMean)
+{
+    try{
+        double sum = 0;
+        for(int i=0;i<runs;i++)
+            {
+                if (m->control_pressed) { return 0; }
+                sum += pow((scorevec[i] - nullMean),2);
+            }
+        return sqrt( (1/double(runs)) * sum );
+    }
+    catch(exception& e) {
+        m->errorOut(e, "TrialSwap2", "getSD");
+        exit(1);
+    }
+}
+/**************************************************************************************************/
+double TrialSwap2::get_zscore (double sd, double nullMean, double initscore)
+{
+    try {
+        return (initscore - nullMean) / sd;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "TrialSwap2", "get_zscore");
+        exit(1);
+    }
+}
+/**************************************************************************************************/
 int TrialSwap2::print_matrix(vector<vector<int> > &matrix, int nrows, int ncols)
 {
     try {