Skip to content

Commit

Permalink
Merge pull request #1023 from brieuclehmann/test_relatedness
Browse files Browse the repository at this point in the history
Add tests for genetic_relatedness
  • Loading branch information
mergify[bot] authored Nov 27, 2020
2 parents 1e66249 + 46b2e3f commit 63566d3
Show file tree
Hide file tree
Showing 4 changed files with 321 additions and 258 deletions.
10 changes: 7 additions & 3 deletions c/tskit/trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -2762,17 +2762,21 @@ genetic_relatedness_summary_func(size_t state_dim, const double *state,
tsk_id_t i, j;
size_t k;
double sumx = 0;
double meanx;
double sumn = 0;
double meanx, ni, nj;

for (k = 0; k < state_dim; k++) {
sumx += x[k];
sumn += args.sample_set_sizes[k];
}

meanx = sumx / (double) state_dim;
meanx = sumx / sumn;
for (k = 0; k < result_dim; k++) {
i = args.set_indexes[2 * k];
j = args.set_indexes[2 * k + 1];
result[k] = (x[i] - meanx) * (x[j] - meanx) / 2;
ni = args.sample_set_sizes[i];
nj = args.sample_set_sizes[j];
result[k] = (x[i] - ni * meanx) * (x[j] - nj * meanx) / 2;
}
return 0;
}
Expand Down
253 changes: 0 additions & 253 deletions python/tests/test_covariance.py

This file was deleted.

Loading

0 comments on commit 63566d3

Please sign in to comment.