6 #include <Sequence/SummStats/Garud.hpp> 13 H1H12(
const SimData &d)
25 set<string> uhaps(d.begin(), d.end());
26 vector<string> vuhaps(uhaps.size());
27 std::move(uhaps.begin(), uhaps.end(), vuhaps.begin());
28 vector<double> hapcounts;
29 hapcounts.reserve(uhaps.size());
30 for(
auto & uh : uhaps)
32 hapcounts.push_back(static_cast<double>(std::count(d.begin(),d.end(),uh)));
34 const double denom =
static_cast<double>(d.size() * (d.size() - 1));
36 for(
auto c : hapcounts)
42 sort(hapcounts.begin(), hapcounts.end(),
43 std::bind(greater<double>(), std::placeholders::_1,
44 std::placeholders::_2));
46 + 2. * hapcounts[0] * hapcounts[1]
47 / std::pow(
double(d.size()), 2.);
49 - double(hapcounts[0] * (hapcounts[0] - 1))
50 / double(d.size() * (d.size() - 1)))
The namespace in which this library resides.