# Help with dimension shape ( DirichletMultinomial )

**URL:** <https://discourse.pymc.io/t/help-with-dimension-shape-dirichletmultinomial/9521>\
**Category:** v3\
**Created:** [May 30, 2022, 2:46am UTC](https://discourse.pymc.io/t/help-with-dimension-shape-dirichletmultinomial/9521 "2022-05-30T02:46:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![whatsbehindthisdoor](https://avatars.discourse-cdn.com/v4/letter/w/9d8465/32.png) [@whatsbehindthisdoor](https://discourse.pymc.io/u/whatsbehindthisdoor)\
**Post date:** [May 30, 2022, 2:46am UTC](https://discourse.pymc.io/t/help-with-dimension-shape-dirichletmultinomial/9521/1 "2022-05-30T02:46:31Z")

</div>

Hello!

I need assistance with using the proper ‘shape’ for my data/model. I recorded the number of green, yellow, and black squares for ten _Wordle_ games for two people and used [this example](https://docs.pymc.io/en/v3.11.4/pymc-examples/examples/mixture_models/dirichlet_mixture_of_multinomials.html) to find the parameters for a single player, but I would like to expand it to encompass two people. Ideally, give each player their own hyper-priors.

Here is my data:

```auto
d = {'Player' : ["P1" if n < 10 else "P2" for n in np.arange(0, 20)],
     'Green': [7, 15,9,7,12,17,12,9,6,12,8,9,8,15,15,11,10,12,11,8], 
     'Yellow': [2,2,9,2,2,2,3,1,6,4,11,0,1,2,3,3,2,2,1,4], 
     'Black': [21,13,12,21,16,11,15,20,18,14,11,21,21,13,12,16,18,16,18,18]
}

df = pd.DataFrame(data=d)

```

and here I sub-select ( which I no longer want to do ) and define some basic input variables:

```auto
# fit for one single player
df_sub = df[df['Player'] == 'P1']
# create observations
obs = df_sub[['Green', 'Yellow', 'Black']].to_numpy()
# types of categories
k = 3
# number of games
n = len(df_sub)
# sum of values in rows
total_count = 30

k, n, total_count

```

and finally, here is the model for a single player:

```auto
with pm.Model() as model:
    frac = pm.Dirichlet("frac", a=np.ones(k))
    conc = pm.Lognormal("conc", mu=1, sigma=1)
    counts = pm.DirichletMultinomial(
        "counts", 
        n=total_count, 
        a=frac*conc,
        shape=(n,k),
        observed=obs
    )

```

**How do I change the shapes of my ‘frac’, ‘conc’, and ‘counts’ to incorporate two players?**

I’m fairly new to pymc3 and bayesian analysis, and although I’ve viewed the tutorial on partial-pooling I’m having trouble generalizing the concepts to the _pm.DirichletMultinomial_ distribution ( which currently has shape 10, 3 for a single player ). Like, if I want a separate lognormal for each player…how would I do that?

Thank you for reading!
