Compute the log likelihood that these samples came from the * specified distribution shifted by the parameter theta. * @param theta the parameter of the PMF, f_theta(x) * @param samples the samples * @param pmf the probability mass function * @return the log likelihood */
| 82 | * @return the log likelihood |
| 83 | */ |
| 84 | static pair<double, unsigned> |
| 85 | computeLikelihood(int theta, const Histogram& samples, const PMF& pmf) |
| 86 | { |
| 87 | double likelihood = 0; |
| 88 | unsigned nsamples = 0; |
| 89 | for (Histogram::const_iterator it = samples.begin(); |
| 90 | it != samples.end(); ++it) { |
| 91 | double p = pmf[it->first + theta]; |
| 92 | unsigned n = it->second; |
| 93 | likelihood += n * log(p); |
| 94 | if (p > pmf.minProbability()) |
| 95 | nsamples += n; |
| 96 | } |
| 97 | return make_pair(likelihood, nsamples); |
| 98 | } |
| 99 | |
| 100 | /** Return the most likely distance between two contigs and the number |
| 101 | * of pairs that support that estimate. */ |
no test coverage detected