for (i = 0; i < n_smpl; ++i) {
const uint8_t *pi = PL[j] + i * PL_len[j];
double *p = pdg[j] + i * 3;
- p[0] = g_q2p[pi[b[j]->n_alleles]]; p[1] = g_q2p[pi[1]]; p[2] = g_q2p[pi[0]];
+ p[0] = g_q2p[pi[2]]; p[1] = g_q2p[pi[1]]; p[2] = g_q2p[pi[0]];
}
}
// iteration
memcpy(flast, f, 4 * sizeof(double));
freq_iter(n_smpl, pdg, f);
for (i = 0; i < 4; ++i) {
- double x = fabs(f[0] - flast[0]);
+ double x = fabs(f[i] - flast[i]);
if (x > eps) eps = x;
}
if (eps < LD_ITER_EPS) break;
{ // calculate r^2
double p[2], q[2], D;
p[0] = f[0] + f[1]; q[0] = 1 - p[0];
- p[1] = f[2] + f[3]; q[1] = 1 - p[1];
+ p[1] = f[0] + f[2]; q[1] = 1 - p[1];
D = f[0] * f[3] - f[1] * f[2];
r = sqrt(D * D / (p[0] * p[1] * q[0] * q[1]));
// fprintf(stderr, "R(%lf,%lf,%lf,%lf)=%lf\n", f[0], f[1], f[2], f[3], r2);