5 * Created by westcott on 12/17/10.
6 * Copyright 2010 Schloss Lab. All rights reserved.
12 /***********************************************************************/
13 EstOutput MemChi2::getValues(vector<SharedRAbundVector*> shared) {
19 int totalOtus = shared[0]->getNumBins();
20 int totalGroups = shared.size();
23 for (int i = 0; i < shared[0]->getNumBins(); i++) {
24 if (shared[0]->getAbundance(i) != 0) { nonZeroA++; }
25 if (shared[1]->getAbundance(i) != 0) { nonZeroB++; }
28 double totalTerm = 1 / (float) totalGroups;
30 for (int i = 0; i < shared[0]->getNumBins(); i++) {
31 int A = shared[0]->getAbundance(i);
32 int B = shared[1]->getAbundance(i);
37 double Aterm = A / (float) nonZeroA;
38 double Bterm = B / (float) nonZeroB;
40 sum += (totalTerm * ((Aterm-Bterm)*(Aterm-Bterm)));
43 data[0] = sqrt((totalOtus * sum));
45 if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
50 m->errorOut(e, "MemChi2", "getValues");
54 /***********************************************************************/