From: Kathryn Iverson Date: Tue, 15 May 2012 20:29:33 +0000 (-0400) Subject: added functions to calculate standard deviation and zscore X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=commitdiff_plain;h=e4470c6d8ddc83db4e55a2c530e804920c62b855 added functions to calculate standard deviation and zscore --- diff --git a/trialSwap2.cpp b/trialSwap2.cpp index 2d25e83..1524890 100644 --- a/trialSwap2.cpp +++ b/trialSwap2.cpp @@ -291,6 +291,30 @@ double TrialSwap2::t_test (double initialscore, int runs, double nullMean, vecto } } /**************************************************************************************************/ +double TrialSwap2::getSD (int runs, vector scorevec, double nullMean) +{ + double sum = 0; + for(int i=0;icontrol_pressed) { return 0; } + sum += pow((scorevec[i] - nullMean),2); + } + return sqrt( (1/runs) * sum ); +} +/**************************************************************************************************/ +double TrialSwap2::get_zscore (double sd, double nullMean, double initscore) +{ + map ztable; + + ztable["0.00"] = 0.5; + + double z; + + z = (initscore - nullMean) / sd; + + return z; +} +/**************************************************************************************************/ int TrialSwap2::print_matrix(vector > &matrix, int nrows, int ncols) { try { diff --git a/trialswap2.h b/trialswap2.h index 924938b..4552219 100644 --- a/trialswap2.h +++ b/trialswap2.h @@ -26,6 +26,8 @@ public: double calc_vratio (int, int, vector, vector); int calc_checker (vector > &, vector, int, int); double calc_c_score (vector > &, vector, int, int); + double get_zscore (double, double, double); + double getSD (int, vector, double); private: @@ -35,7 +37,7 @@ private: int print_matrix(vector > &, int, int); - + }; #endif