X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=trialSwap2.cpp;h=4cff4260ad5754fb4c0347747d20d0439df3f5d6;hb=3504e4e2feeb05aabb0c79aa42cb696522030924;hp=2d25e835cbd5608bc1c4f4c6cc67397155f2c834;hpb=0caf3fbabaa3ece404f8ce77f4c883dc5b1bf1dc;p=mothur.git diff --git a/trialSwap2.cpp b/trialSwap2.cpp index 2d25e83..4cff426 100644 --- a/trialSwap2.cpp +++ b/trialSwap2.cpp @@ -50,9 +50,10 @@ double TrialSwap2::calc_c_score (vector > &co_matrix, vector ro } } - cscore = cscore/(double)(nrows*(nrows-1)/2); + //cscore = cscore/(double)(nrows*(nrows-1)/2); //not normalized //cout << "normalized c score: " << normcscore/nonzeros << endl; - + cscore = normcscore/(double)nonzeros; + return cscore; } catch(exception& e) { @@ -291,6 +292,34 @@ double TrialSwap2::t_test (double initialscore, int runs, double nullMean, vecto } } /**************************************************************************************************/ +double TrialSwap2::getSD (int runs, vector scorevec, double nullMean) +{ + try{ + double sum = 0; + for(int i=0;icontrol_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 > &matrix, int nrows, int ncols) { try {