]> git.donarmstrong.com Git - mothur.git/blob - efron.cpp
added boneh, efron, and solow calculators
[mothur.git] / efron.cpp
1 /*
2  *  efron.cpp
3  *  Mothur
4  *
5  *  Created by Thomas Ryabin on 5/13/09.
6  *  Copyright 2009 __MyCompanyName__. All rights reserved.
7  *
8  */
9
10 #include "efron.h"
11 #include <math.h>
12
13 /***********************************************************************/
14 EstOutput Efron::getValues(SAbundVector* rank){
15
16         try {
17                 data.resize(1,0);
18                 
19                 if(m > rank->size()-1) {
20                         cout << "Error in the 'efron' calculator. 'size' must be less than the length of the smalled sabund vector.\n";
21                         data[0] = 0;
22                         return data;
23                 }
24                 
25                 double sum = 0;
26                 for(int i = 1; i < rank->size(); i++)
27                         sum += pow(-1, (double)(i+1)) * pow(((double)m / (double)(rank->size()-1)), i) * (double)(rank->get(i));
28
29                 data[0] = sum;
30                 
31                 return data;
32         }
33         catch(exception& e) {
34                 cout << "Standard Error: " << e.what() << " has occurred in the Coverage class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
35                 exit(1);
36         }
37         catch(...) {
38                 cout << "An unknown error has occurred in the Coverage class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
39                 exit(1);
40         }       
41 };
42
43
44 /***********************************************************************/