Estimate the distance between two contigs using the difference of * the population mean and the sample mean. * @param numPairs [out] the number of pairs that agree with the * expected distribution * @return the estimated distance */
| 161 | * @return the estimated distance |
| 162 | */ |
| 163 | static int estimateDistanceUsingMean( |
| 164 | const std::vector<int>& samples, const PMF& pmf, |
| 165 | unsigned& numPairs) |
| 166 | { |
| 167 | Histogram h(samples.begin(), samples.end()); |
| 168 | int d = (int)round(pmf.mean() - h.mean()); |
| 169 | |
| 170 | // Count the number of samples that agree with the distribution. |
| 171 | unsigned n = 0; |
| 172 | for (Histogram::const_iterator it = h.begin(); |
| 173 | it != h.end(); ++it) |
| 174 | if (pmf[it->first + d] > pmf.minProbability()) |
| 175 | n += it->second; |
| 176 | |
| 177 | numPairs = n; |
| 178 | return d; |
| 179 | } |
| 180 | |
| 181 | /** Estimate the distance between two contigs using the difference of |
| 182 | * the population median and the sample median. |
no test coverage detected