# Mixture of vector valued random variables

#1

In my data set there are D number of observations. Each observation is an N dimensional binary vector.
I want to represent this data as a K mixture of N-D Binomial distributions.

model = pm.Model()
K = 4
N = 8
with model:

w = pm.Dirichlet('w', a = np.ones(K), shape = K)

p_ = pm.Dirichlet('p_', a = np.ones((K, N)), shape = (K, N))

components = []
for k in range(K):
components.append(pm.Bernoulli.dist(p = p_[k]))
like = pm.Mixture('like', w=w, comp_dists = components, observed = data)


I get the following error.
ValueError: Input dimension mis-match. (input[0].shape[2] = 4, input[1].shape[2] = 8)

How can I fix this?
Also any way I could avoid the for loop please?
thanks

#2

I think your data should be of shape (N, K).
your component can be set with:
components = pm.Bernoulli.dist(p = p_, shape = (K, N))

#3

There are D number of observations, each observation is N dimensional binary vector. So my data is a D \times N matrix.