]> git.donarmstrong.com Git - mothur.git/blobdiff - calculator.cpp
got rid of extra temp files in dist.seqs
[mothur.git] / calculator.cpp
index ffd452a479c16c9df3e133d09576eac67d33c5fa..c45ddbffae174303b07e47b94d5183a37339022a 100644 (file)
@@ -746,96 +746,7 @@ void KS2SampleTest::doKSTest(vector<double> abun1, vector<double> abun2)//abun1
 }
 
 /***********************************************************************/
-double logS(double num)
-{
-       return -(1-num)*log(1-num)/num;
-}
 
-/***********************************************************************/
-/*void LogSD::doLogSD(vector<double> indVec, vector<double> specVec) //indVec = individuals vector, specVec = species vector
-{      try {
-               VecCalc vecCalc;
-               double numSpec = vecCalc.sumElements(specVec);//numSpec = The total number of species
-               cout << "number of species = " << numSpec << "\n";
-               double numInd = vecCalc.sumElements(vecCalc.multVecs(indVec, specVec));
-               double snRatio = numSpec/numInd;
-               double x = .5;
-               double step = .4999999999;
-               while(fabs(snRatio - logS(x)) > .00001) //This uses a binary search to find the value of x.
-               {
-                       if(logS(x) > snRatio)
-                               x += step;
-                       else
-                               x -= step;
-                       step /= 2;
-               }
-               double alpha = numInd*(1-x)/x;
-       
-               int ind;
-               cout << "Number of individuals:"; //Ask the user for the number of individuals.
-               cin >> ind;
-               double spec = alpha*pow(x, ind)/ind;
-               cout << "Number of species expected = " << spec << "\n" << "X value = " << x << "\n" << "Alpha value= " << alpha << "\n";//Outputs the number of species expected with the given number of individuals.
-       
-               vector<double> obsSpec;
-               vector<double> cObsSpec;
-               vector<double> expSpec;
-               vector<double> cExpSpec;
-               vector<double> cDiff;
-       
-               // Generates the cumulative observed species vector.
-               int oct = 1;
-               double octSumObs = 0;
-               for(int y = 0; y < specVec.size(); y++)
-               {
-                       if(indVec.at(y) - .5 < pow(2.0, oct))
-                               octSumObs += specVec.at(y);
-                       else
-                       {
-                               obsSpec.push_back(octSumObs);
-                               octSumObs = specVec.at(y);
-                               oct++;
-                       }
-                       if(y == specVec.size()-1)
-                               obsSpec.push_back(octSumObs);
-               }
-               cObsSpec = vecCalc.genCVec(obsSpec);
-               cObsSpec = vecCalc.add(cObsSpec,-.5);
-       
-               // Generates the cumulative expected species vector.
-               oct = 1;
-               double octSumExp = 0;
-               for(int g = 1; g <= indVec.at(indVec.size()-1); g++)
-               {
-                       if(g - .5 < pow(2.0, oct))
-                               octSumExp += alpha*pow(x,g)/(g);
-                       else
-                       {
-                               expSpec.push_back(octSumExp);
-                               octSumExp = alpha*pow(x,g)/(g);
-                               oct++;
-                       }
-                       if(g == indVec.at(indVec.size()-1))
-                               expSpec.push_back(octSumExp);
-               }
-               cExpSpec = vecCalc.genCVec(expSpec);
-       
-               // Statistical Analysis
-               double dTStat = vecCalc.findDStat(cObsSpec, cExpSpec, numSpec);
-               cout << "D Test Statistic = " << dTStat << "\n";
-               cout << ".05 confidence value = " << .89196/sqrt(numSpec) << "\n";
-               cout << ".01 confidence value = " << 1.0471/sqrt(numSpec) << "\n\n";
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the LogSD class Function doLogSD. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the LogSD class function doLogSD. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
-}*/
-/***********************************************************************/
 void QStatistic::doQStat(vector<double> vec)//vec = The data vector.
 {      try {
                VecCalc vecCalc;
@@ -952,7 +863,7 @@ double TDTable::getConfLimit(int row, int col) //Rows are the degrees of freedom
                //Found on http://www.vgtu.lt/leidiniai/elektroniniai/Probability.pdf/Table%203.pdf
 
                //Confidence Level        .90    .95     .975     .99    .995     .999    .9995
-               double values[33][7] = {{3.078, 6.314,  12.706, 31.821, 63.656, 318.289, 636.578},
+               double values[30][7] = {{3.078, 6.314,  12.706, 31.821, 63.656, 318.289, 636.578},
                                                        {1.886, 2.920,  4.303,  6.965,  9.925,  22.328, 31.600},
                                                            {1.638,     2.353,  3.182,  4.541,  5.841,  10.214, 12.924},
                                                            {1.533,     2.132,  2.776,  3.747,  4.604,  7.173,  8.610},
@@ -981,10 +892,8 @@ double TDTable::getConfLimit(int row, int col) //Rows are the degrees of freedom
                                                                {1.314, 1.703,  2.052,  2.473,  2.771,  3.421,  3.689},
                                                                {1.313, 1.701,  2.048,  2.467,  2.763,  3.408,  3.674},
                                                                {1.311, 1.699,  2.045,  2.462,  2.756,  3.396,  3.660},
-                                                               {1.310, 1.697,  2.042,  2.457,  2.750,  3.385,  3.646},
-                                                               {1.296, 1.671,  2.000,  2.390,  2.660,  3.232,  3.460},
-                                                               {1.289, 1.658,  1.980,  2.358,  2.617,  3.160,  3.373},
-                                                               {1.282, 1.645,  1.960,  2.326,  2.576,  3.091,  3.291}};
+                                                               {1.310, 1.697,  2.042,  2.457,  2.750,  3.385,  3.646}};
+                                                               
                return values[row][col];
        }
        catch(exception& e) {