-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More testing (plus bug fix) #17
Conversation
I think this might be the problem: https://github.com/cdcent/cfa-ngm-widget/blob/main/ngm/__init__.py#L67 Should be? return np.transpose(beta) * (s_i / n.sum()) * s_vax |
That does in fact look suspicious. Checking numpy's broadcasting, that looks like it goes into columns, so
But our docs say it should go into rows https://github.com/cdcent/cfa-ngm-widget/blob/f16d72085fcac4fe4f9af37733e28b2f4fd8750c/docs/approach.md?plain=1#L27, https://github.com/cdcent/cfa-ngm-widget/blob/f16d72085fcac4fe4f9af37733e28b2f4fd8750c/docs/approach.md?plain=1#L43 |
But I disagree on the solution, you need to transpose it back again at the end. return (beta.T * ((s_i / n.sum()) * s_vax)).T |
As of implementing my version in 8e6d602, we pass the KR test and fail several others (test_vax_beta, test_simulate) |
We bootstrapped ourselves to the transposed matrix, though, so that's not entirely surprising? |
52500c5
to
ef9a0a6
Compare
ef9a0a6
to
a0bedbc
Compare
Okay @swo, @paigemiller, @dinacmistry, this is ready for a (second) look |
This PR's scope has increased slightly having found the below bug in matrix transposition. It now includes:
pytest
run on PRsngm.get_R()
ngm.run_ngm()
which repeatedly applies the NGM (per slide 24 here)test_one_step()
tests that applying one step of the NGM from the nominal "stationary" distribution:test_eigenvectors()
plays out the NGM from one case for many (200) steps and compares to the eigenvectortest_vax_beta
is a correctness test which had the matrix transposed the same way asget_R
test_simulate
is a consistency-of-output test, so I re-ran the code and updated the outputs