double ci = 0;
double maxRank = (double)rank->getMaxRank();
- int sampled = rank->getNumSeqs();
- int sobs = rank->getNumBins();
+ double sampled = (double)rank->getNumSeqs();
+ double sobs = (double)rank->getNumBins();
double firstTerm = 0;
double secondTerm = 0;
if(sobs != 0){
double simnum=0.0000;
- for(int i=1;i<=maxRank;i++){
+ for(unsigned long int i=1;i<=maxRank;i++){
simnum += (double)(rank->get(i)*i*(i-1));
}
+
+ simpson = simnum / (sampled*(sampled-1));
- simpson = simnum / (double)(sampled*(sampled-1));
-
- for(int i=1;i<=maxRank;i++){
+ for(unsigned long int i=1;i<=maxRank;i++){
double piI = (double) i / (double)sampled;
firstTerm += rank->get(i) * pow(piI, 3);
secondTerm += rank->get(i) * pow(piI, 2);
}
- double var = (4.0 / (double)sampled) * (firstTerm - secondTerm*secondTerm);
+ double var = (4.0 / sampled) * (firstTerm - secondTerm*secondTerm);
ci = 1.95 * pow(var, 0.5);
}
return data;
}
catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the Simpson class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ m->errorOut(e, "Simpson", "getValues");
exit(1);
}
- catch(...) {
- cout << "An unknown error has occurred in the Simpson class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
}
/***********************************************************************/