5 * Created by Sarah Westcott on 1/7/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
12 /***********************************************************************/
14 EstOutput Shannon::getValues(SAbundVector* rank){
16 //vector<double> shannonData(3,0);
19 double shannon = 0.0000; //hprime
22 double maxRank = rank->getMaxRank();
23 int sampled = rank->getNumSeqs();
24 int sobs = rank->getNumBins();
26 for(int i=1;i<=maxRank;i++){
27 double p = ((double) i)/((double)sampled);
28 shannon += (double)rank->get(i)*p*log(p); //hprime
29 hvara += (double)rank->get(i)*p*pow(log(p),2);
33 double hvar = (hvara-pow(shannon,2))/(double)sampled+(double)(sobs-1)/(double)(2*sampled*sampled);
38 ci = 1.96*pow(hvar,0.5);
41 double shannonhci = shannon + ci;
42 double shannonlci = shannon - ci;
48 if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
49 if (isnan(data[1]) || isinf(data[1])) { data[1] = 0; }
50 if (isnan(data[2]) || isinf(data[2])) { data[2] = 0; }
55 m->errorOut(e, "Shannon", "getValues");
60 /***********************************************************************/