#include <math.h>
/***********************************************************************/
+//This solves for the value of 'v' using a binary search.
double Boneh::getV(double f1, double n, double rs) {
//cout << "f1 = " << f1 << "\nn = " << n << "\nrs = " << rs << "\n\n";
+ if(rs == 0)
+ return 0;
+
double accuracy = .0001;
double v = 100000.0;
double step = v/2;
ls = v* (1 - pow((1 - f1/(n*v)), n));
step /= 2;
- // cout << "ls = " << ls << "\n";
+ //cout << "ls = " << ls << "\n";
}
return v;
bool valid = false;
double sum = 0;
- double n = (double)rank->size() - 1;
+ double n = (double)rank->getNumSeqs();
double f1 = (double)rank->get(1);
for(int i = 1; i < rank->size(); i++)
double v = getV(f1, n, sum);
- // cout << "v = " << v << "\n";
+ //cout << "v = " << v << "\n";
+
sum = 0;
- for(int j = 1; j < rank->size(); j++)
- sum += pow(1 - (double)rank->get(j) / n, n) * (1 - pow(1 - (double)rank->get(j) / n, m)) + v * pow(1 - f1/(n*v), n) * (1 - pow(1 - f1/(n*v), m));
-
+ for(int j = 1; j < rank->size(); j++) {
+ double Xi = 0; //I didn't know what this was, simply replace the 0
+ //with the appropriate expression for the boneh calculator
+ //to work.
+ 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));
+ }
}
data[0] = sum;
#include "efron.h"
#include "boneh.h"
#include "solow.h"
-
+#include "shen.h"
#include "coverage.h"
}else if (globaldata->Estimators[i] == "solow") {
convert(globaldata->getSize(), size);
cDisplays.push_back(new CollectDisplay(new Solow(size), new OneColumnFile(fileNameRoot+"solow")));
+ }else if (globaldata->Estimators[i] == "shen") {
+ convert(globaldata->getSize(), size);
+ cDisplays.push_back(new CollectDisplay(new Shen(size), new OneColumnFile(fileNameRoot+"shen")));
}
}
}
try {
data.resize(1,0);
- if(m > rank->size()-1) {
- cout << "Error in the 'efron' calculator. 'size' must be less than the length of the smalled sabund vector.\n";
+ double n = (double)rank->getNumSeqs();
+ if(m > n) {
+ cout << "Error in the 'efron' calculator. 'size' must be less than the length of the smallest sabund vector.\n";
data[0] = 0;
return data;
}
double sum = 0;
for(int i = 1; i < rank->size(); i++)
- sum += pow(-1, (double)(i+1)) * pow(((double)m / (double)(rank->size()-1)), i) * (double)(rank->get(i));
+ sum += pow(-1, (double)(i+1)) * pow(((double)m / n), i) * (double)(rank->get(i));
data[0] = sum;
//input defaults for calculators
if (commandName == "collect.single") {
- if ((calc == "default") || (calc == "")) { calc = "sobs-chao-ace-jack-shannon-npshannon-simpson-efron-boneh-solow"; }
+ if ((calc == "default") || (calc == "")) { calc = "sobs-chao-ace-jack-shannon-npshannon-simpson-efron-boneh-solow-shen"; }
Estimators.clear();
splitAtDash(calc, Estimators);
}
splitAtDash(calc, Estimators);
}
if (commandName == "summary.single") {
- if ((calc == "default") || (calc == "")) { calc = "sobs-chao-ace-jack-shannon-npshannon-simpson-efron-boneh-solow"; }
+ if ((calc == "default") || (calc == "")) { calc = "sobs-chao-ace-jack-shannon-npshannon-simpson-efron-boneh-solow-shen"; }
Estimators.clear();
splitAtDash(calc, Estimators);
}
--- /dev/null
+/*
+ * shen.cpp
+ * Mothur
+ *
+ * Created by Thomas Ryabin on 5/18/09.
+ * Copyright 2009 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include "shen.h"
+#include <math.h>
+
+
+/***********************************************************************/
+EstOutput Shen::getValues(SAbundVector* rank){
+
+ try {
+ data.resize(1,0);
+
+ double n = (double)rank->getNumSeqs();
+ double f1 = (double)rank->get(1);
+
+ double D_rare = 0; //I didn't know what this was. Simply replace the '0' with the appropriate expression.
+ double C_rare = 1; //I didn't know what this was. Simply replace the '1' with the appropriate expression.
+ double Y_rare = 1; //I didn't know what this was. Simply replace the '1' with the appropriate expression.
+
+ double f0 = D_rare/C_rare + f1/C_rare * Y_rare*Y_rare - D_rare;
+
+ data[0] = f0 * (1 - pow(1 - f1/n/f0, m));
+
+ return data;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the Coverage class Function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the Coverage class function getValues. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+};
+
+
+/***********************************************************************/
--- /dev/null
+#ifndef SHEN_H
+#define SHEN_H
+
+/*
+ * shen.h
+ * Mothur
+ *
+ * Created by Thomas Ryabin on 5/18/09.
+ * Copyright 2009 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include "calculator.h"
+
+/* This class implements the shen calculator on single group.
+ It is a child of the calculator class. */
+
+/***********************************************************************/
+
+class Shen : public Calculator {
+
+public:
+ Shen(int size) : m(size), Calculator("shen", 1, false) {};
+ EstOutput getValues(SAbundVector*);
+ EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
+private:
+ int m;
+};
+
+
+/***********************************************************************/
+
+#endif
try {
data.resize(1,0);
- double n = (double)rank->size() - 1;
+ double n = (double)rank->getNumSeqs();
double f1 = (double)rank->get(1);
double f2 = (double)rank->get(2);
#include "efron.h"
#include "boneh.h"
#include "solow.h"
+#include "shen.h"
//**********************************************************************************************************************
}else if (globaldata->Estimators[i] == "solow") {
convert(globaldata->getSize(), size);
sumCalculators.push_back(new Solow(size));
+ }else if (globaldata->Estimators[i] == "shen") {
+ convert(globaldata->getSize(), size);
+ sumCalculators.push_back(new Shen(size));
}
}
}
single["efron"] = "efron";
single["boneh"] = "boneh";
single["solow"] = "solow";
+ single["shen"] = "shen";
single["default"] = "default";
}
catch(exception& e) {
summary["efron"] = "efron";
summary["boneh"] = "boneh";
summary["solow"] = "solow";
+ summary["shen"] = "shen";
summary["default"] = "default";
}
catch(exception& e) {