5 * Created by Thomas Ryabin on 5/13/09.
6 * Copyright 2009Schloss Lab UMASS Amherst. All rights reserved.
13 /***********************************************************************/
15 //This solves for the value of 'v' using a binary search.
16 double Boneh::getV(double f1, double n, double rs) {
21 double accuracy = .0001;
24 double ls = v * (1 - pow((1 - f1/(n*v)), n));
26 while(abs(ls - rs) > accuracy) {
27 if(ls > rs) { v -= step; }
30 ls = v * (1 - pow((1 - f1/(n * v)), n));
37 /***********************************************************************/
38 EstOutput Boneh::getValues(SAbundVector* sabund){
46 double n = (double)sabund->getNumSeqs();
49 double f1 = (double)sabund->get(1);
51 for(int i = 1; i < sabund->size(); i++){
52 sum += (double)sabund->get(i) * exp(-i);
55 if(sabund->get(1) > sum)
60 for(int j = 1; j < sabund->size(); j++){
61 sum += sabund->get(j) * pow((1 - (double)j / n), n);
64 double v = getV(f1, n, sum);
67 for(int j = 1; j < sabund->size(); j++) {
68 for (int i = 0; i < sabund->get(j); i++) {
69 sum += pow(1 - j / n, n) * (1 - pow(1 - j / n, f));
72 sum += v * pow(1 - f1/(n*v), n) * (1 - pow(1 - f1/(n*v), f));
80 m->errorOut(e, "Boneh", "getValues");
86 /***********************************************************************/