libsequence  1.9.5
thetaw.cc
1 #include <algorithm>
2 #include <stdexcept>
3 #include <Sequence/AlleleCountMatrix.hpp>
4 #include <Sequence/summstats/auxillary.hpp>
5 
6 namespace Sequence
7 {
8  double
10  {
11  double w = 0.0;
12  for (std::size_t i = 0; i < ac.counts.size(); i += ac.ncol)
13  {
14  std::uint32_t nsam = 0, nstates = 0;
15  for (std::size_t j = i; j < i + ac.ncol; ++j)
16  {
17  if (ac.counts[j] > 0)
18  {
19  nsam += static_cast<std::uint32_t>(
20  ac.counts[j]);
21  nstates++;
22  }
23  }
24  if (nstates > 1)
25  {
26  auto denom = summstats_aux::a_sub_n(nsam);
27  w += static_cast<double>(nstates - 1) / denom;
28  }
29  }
30  return w;
31  }
32 
33 } // namespace Sequence
The namespace in which this library resides.
double thetaw(const AlleleCountMatrix &ac)
Watterson&#39;s theta.
Definition: thetaw.cc:9
Matrix representation of allele counts in a VariantMatrix To be constructed.