Created
October 22, 2022 03:10
-
-
Save bgnori/09a446f1d8e5007d1e29a092a626d7a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def redbrain(n=100, b=0.3, sz=100): | |
return [(x, np.random.binomial(n - x, b)) for x in np.random.binomial(n, 0.5, sz)] | |
def foo(n, sz): | |
d = {} | |
for i in range(1, 20): | |
p = i * 0.05 | |
xs = redbrain(n=n, b=p, sz=sz) | |
for an, qn in xs: | |
dd = d[an+qn] if an+qn in d else dict() | |
zs = dd[p] if p in dd else [] | |
zs.append((an, qn)) | |
dd[p] = zs | |
d[an+qn] = dd | |
return d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment