5 * Created by Sarah Westcott on 1/7/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
12 /***********************************************************************/
13 EstOutput Chao1::getValues(SAbundVector* rank){
17 double sobs = (double)rank->getNumBins();
19 double singles = (double)rank->get(1);
20 double doubles = (double)rank->get(2);
21 double chaovar = 0.0000;
23 double chao = sobs + singles*(singles-1)/(2*(doubles+1));
25 if(singles > 0 && doubles > 0){
26 chaovar = singles*(singles-1)/(2*(doubles+1))
27 + singles*pow(2*singles-1, 2)/(4*pow(doubles+1,2))
28 + pow(singles, 2)*doubles*pow(singles-1, 2)/(4*pow(doubles+1,4));
30 else if(singles > 0 && doubles == 0){
31 chaovar = singles*(singles-1)/2 + singles*pow(2*singles-1, 2)/4 - pow(singles, 4)/(4*chao);
33 else if(singles == 0){
34 chaovar = sobs*exp(-1*rank->getNumSeqs()/sobs)*(1-exp(-1*rank->getNumSeqs()/sobs));
37 double chaohci, chaolci;
40 double denom = pow(chao-sobs,2);
41 double c = exp(1.96*pow((log(1+chaovar/denom)),0.5));
42 chaolci = sobs+(chao-sobs)/c;//chao lci
43 chaohci = sobs+(chao-sobs)*c;//chao hci
46 double p = exp(-1*rank->getNumSeqs()/sobs);
47 chaolci = sobs/(1-p)-1.96*pow(sobs*p/(1-p), 0.5);
48 chaohci = sobs/(1-p)+1.96*pow(sobs*p/(1-p), 0.5);
49 if(chaolci < sobs){ chaolci = sobs; }
56 if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
57 if (isnan(data[1]) || isinf(data[1])) { data[1] = 0; }
58 if (isnan(data[2]) || isinf(data[2])) { data[2] = 0; }
63 cout << "Standard Error: " << e.what() << " has occurred in the Chao1 class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
67 cout << "An unknown error has occurred in the Chao1 class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
72 /***********************************************************************/