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?
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
andY
, and I have a GMM trained on the[X Y]
dataset. Now I'd like to generate values forY
based on an array of values ofX
, but instead of just getting the mean I'd like to obtain multiple (let's sayN
) values sampled according to the mixture distribution. One way to accomplish this is as follows:However, this requires a loop over all values of
X
(whichpredict
avoids). Is there a better/more performant way to get this same result?