5 * Created by Thomas Ryabin on 5/13/09.
6 * Copyright 2009 __MyCompanyName__. All rights reserved.
13 /***********************************************************************/
14 //This solves for the value of 'v' using a binary search.
15 double Boneh::getV(double f1, double n, double rs) {
17 //cout << "f1 = " << f1 << "\nn = " << n << "\nrs = " << rs << "\n\n";
22 double accuracy = .0001;
25 double ls = v * (1 - pow((1 - f1/(n*v)), n));
27 //cout << "ls = " << ls << "\n";
29 while(abs(ls - rs) > accuracy) {
35 ls = v* (1 - pow((1 - f1/(n*v)), n));
38 //cout << "ls = " << ls << "\n";
44 /***********************************************************************/
45 EstOutput Boneh::getValues(SAbundVector* rank){
52 double n = (double)rank->getNumSeqs();
53 double f1 = (double)rank->get(1);
55 for(int i = 1; i < rank->size(); i++)
56 sum += (double)rank->get(i) * exp(-i);
58 if(rank->get(1) > sum)
63 for(int j = 1; j < rank->size(); j++)
64 sum += rank->get(j) * pow((1 - (double)j / n), n);
66 double v = getV(f1, n, sum);
68 //cout << "v = " << v << "\n";
72 for(int j = 1; j < rank->size(); j++) {
73 double Xi = 0; //I didn't know what this was, simply replace the 0
74 //with the appropriate expression for the boneh calculator
76 sum += pow(1 - Xi / n, n) * (1 - pow(1 - Xi / n, m)) + v * pow(1 - f1/(n*v), n) * (1 - pow(1 - f1/(n*v), m));
85 cout << "Standard Error: " << e.what() << " has occurred in the Coverage class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
89 cout << "An unknown error has occurred in the Coverage class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
95 /***********************************************************************/