How can we build a mixture of mixtures?

trying this :

mu_g = np.arange(5,data_max,5)
lp = np.exp(ln_mix.logp(np.asarray([mu_g])))

gives this error message :

ValueError: Input dimension mis-match. (input[0].shape[1] = 40, input[1].shape[1] = 5)

where 40 is the size of mu_g, and 5 is the number of components in the ln_mix mixture.

So I guess the following : when building mixture from multidimensional distribution, we have to provide, and copy input values, for each dimension …?

So I tried to format my input data with this idea :

So starting with this input data :
array([ 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65,
70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130,
135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200])

I structured it this way :

array([[  5,   5,   5,   5,   5],
       [ 10,  10,  10,  10,  10],
       [ 15,  15,  15,  15,  15],
       [ 20,  20,  20,  20,  20],
       [ 25,  25,  25,  25,  25],
       [ 30,  30,  30,  30,  30],
       [ 35,  35,  35,  35,  35],
       [ 40,  40,  40,  40,  40],
       [ 45,  45,  45,  45,  45],
       [ 50,  50,  50,  50,  50],
       [ 55,  55,  55,  55,  55],
...

In that case the logp function call is accepted ! :wink:

But, the result of the logp seem in the wrong format…This is the error message get when trying to put the result as a weight vector for a new mixture.

ValueError: Not enough dimensions on g_w to reduce on axis -1

When trying to access one lopg value with the [ ] operator, I get this error message :

ValueError: The index list is longer (size 1) than the number of dimensions of the tensor(namely 0). You are asking for a dimension of the tensor that does not exist! You might need to use dimshuffle to add extra dimension to your tensor.

From this error messages, I guess that the logp output is a unique value, where I expect it should be a vector.

So I’m still blocked to get rid of that last loop in my model…