Difference between revisions of "830 - Haplotyper::SummarizeOptions()"
From Genome Analysis Wiki
Jump to navigationJump to search (Created page with "<code lang="cpp"> float Haplotyper::SummarizeOptions(float * vector, float ** left, float ** right, float theta, int first, int second) { right[0][0] = (1. - theta) * (...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | < | + | <source lang="cpp"> |
float Haplotyper::SummarizeOptions(float * vector, float ** left, float ** right, float theta, int first, int second) | float Haplotyper::SummarizeOptions(float * vector, float ** left, float ** right, float theta, int first, int second) | ||
Line 13: | Line 13: | ||
for (int k = 0; k < states; k++) | for (int k = 0; k < states; k++) | ||
{ | { | ||
− | for (int l = 0; l < | + | for (int l = 0; l < k; l++, probability++) |
{ | { | ||
left[1][1] += *probability; | left[1][1] += *probability; |
Latest revision as of 15:55, 2 October 2013
float Haplotyper::SummarizeOptions(float * vector, float ** left, float ** right, float theta, int first, int second)
{
right[0][0] = (1. - theta) * (1. - theta);
right[1][0] = right[0][1] = (1. - theta) * theta / states;
right[1][1] = theta / states * theta / states;
left[0][0] = left[1][0] = left[0][1] = left[0][0] = 0.;
float * probability = vector;
for (int k = 0; k < states; k++)
{
for (int l = 0; l < k; l++, probability++)
{
left[1][1] += *probability;
if (first == k || first == l) left[0][1] += *probability * 0.5;
if (second == k || second == l) left[1][0] += *probability * 0.5;
if (first == k && second == l || first == l && second == k) left[0][0] += *probability * 0.5;
}
left[1][1] += *probability;
if (first == k) left[0][1] += *probability;
if (second == k) left[1][0] += *probability;
if (first == k && second == l) left[0][0] += *probability;
}
return left[0][0] * right[0][0] + left[1][0] * right[1][0] +
left[0][1] * right[0][1] + left[1][1] * right[1][1];
}