Skip to content

Instantly share code, notes, and snippets.

@WillKoehrsen
Last active January 12, 2021 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WillKoehrsen/c4d0342738696a0723030647fce01f8a to your computer and use it in GitHub Desktop.
Save WillKoehrsen/c4d0342738696a0723030647fce01f8a to your computer and use it in GitHub Desktop.
# Observations from multiple trips
c = np.array([[3, 2, 1],
[2, 3, 1],
[3, 2, 1],
[2, 3, 1]])
with pm.Model() as model:
# Parameters are a dirichlet distribution
parameters = pm.Dirichlet('parameters', a=alphas, shape=3)
# Observed data is a multinomial distribution
observed_data = pm.Multinomial(
'observed_data', n=6, p=parameters, shape=3, observed=c)
trace = pm.sample(draws=1000, chains=2, tune=500, discard_tuned_samples=True)
@smalik89
Copy link

Wonderful article! In the 'c' parameter, what if you saw cubs there and now the total wasn't 6 for each trip to the zoo. For example one trip you saw [3, 2, 3], would that work and would any other parameter need to be changed?
Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment