X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=trialSwap2.cpp;h=9959443c9ffbb0c411dfcd0fc6dd6920fbe6f5c8;hp=1524890c9c9ddda83a1d777982e59ac23ebb037b;hb=b206f634aae1b4ce13978d203247fb64757d5482;hpb=e4470c6d8ddc83db4e55a2c530e804920c62b855 diff --git a/trialSwap2.cpp b/trialSwap2.cpp index 1524890..9959443 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) { @@ -148,7 +149,7 @@ int TrialSwap2::calc_combo (int nrows, int ncols, vector > &nullmatr { try { //need to transpose so we can compare rows (row-major order) - int tmpnrows = nrows; + //int tmpnrows = nrows; vector > tmpmatrix; vector tmprow; @@ -293,26 +294,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 ); + 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) { - map ztable; - - ztable["0.00"] = 0.5; - - double z; - - z = (initscore - nullMean) / sd; - - return z; + 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)