Doing conditional sampling for multiple values
Closed this issue · 1 comments
I would like to perform a specific kind of sampling, and I'm not sure what is the best way to go about it. Say I have two variables (1d arrays) X
and Y
, and I have a GMM trained on the [X Y]
dataset. Now I'd like to generate values for Y
based on an array of values of X
, but instead of just getting the mean I'd like to obtain multiple (let's say N
) values sampled according to the mixture distribution. One way to accomplish this is as follows:
Y_sampled = np.empty((len(X), N))
for i in range(len(X)):
Y_sampled[i, :] = gmm.condition([0], X[i]).sample(N)
However, this requires a loop over all values of X
(which predict
avoids). Is there a better/more performant way to get this same result?
Hi @nardi ,
unfortunately there is no faster way to do this at the moment. If you have an idea how to implement this efficiently, let me know!