X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=rarecalc.cpp;fp=rarecalc.cpp;h=9145061255d415eb7a48749bdbaaa405b78425fd;hb=0caf3fbabaa3ece404f8ce77f4c883dc5b1bf1dc;hp=0000000000000000000000000000000000000000;hpb=1b73ff67c83892a025e597dabd9df6fe7b58206a;p=mothur.git diff --git a/rarecalc.cpp b/rarecalc.cpp new file mode 100644 index 0000000..9145061 --- /dev/null +++ b/rarecalc.cpp @@ -0,0 +1,53 @@ +/* + * rarecalc.cpp + * Dotur + * + * Created by Sarah Westcott on 1/7/09. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. + * + */ + +#include "rarecalc.h" + +/***********************************************************************/ + +EstOutput RareCalc::getValues(int n){ + try { + EstOutput output(3,0); + + double richness = (double)numBins; + double varS = 0.0000; + + double varTerm1 = 0.0000; + double varTerm2 = 0.0000; + + double rSummation = 0; + for(int i=0;iget(i); + rSummation += (bMatrix[N_ni][n]); + + varTerm1 += (bMatrix[N_ni][n] * (1.0 - bMatrix[N_ni][n] / bMatrix[numSeqs][n])); + + for(int j=i+1;jget(j)][n] - bMatrix[N_ni][n] * bMatrix[numSeqs-bins->get(j)][n] / bMatrix[numSeqs][n]); + } + + } + richness -= (rSummation / bMatrix[numSeqs][n]); + varS = (varTerm1 + 2 * varTerm2) / bMatrix[numSeqs][n]; + float sd = pow(varS, 0.5); + + + output[0] = richness; + output[1] = richness - 1.96 * sd; + output[2] = richness + 1.96 * sd; + + return output; + } + catch(exception& e) { + m->errorOut(e, "RareCalc", "getValues"); + exit(1); + } +} + +/***********************************************************************/