def sample_gaussian2(means, cv, size, random_state, mins, maxes):

    def once(size1):
        g = random_state.multivariate_normal(means, cv, size1).T
        g = g.reshape(len(means), (- 1))
        mask = (g >= mins[:, None]).all(axis=0)
        mask &= (g <= maxes[:, None]).all(axis=0)
        return g[:, mask]
    g = once(size)
    generated = size
    while (g.shape[1] < size):
        fac = ((1.0 * g.shape[1]) / size)
        togen = (((size - g.shape[1]) * generated) // g.shape[1])
        g1 = once(togen)
        generated = (generated + togen)
        g = numpy.append(g, g1, axis=1)
    return g[:, :size]
def sample_gaussian2(means, cv, size, random_state, mins, maxes):

    def once(size1):
        g = random_state.multivariate_normal(means, cv, size1).T
        g = g.reshape(len(means), (- 1))
        mask = (g >= mins[:, None]).all(axis=0)
        mask &= (g <= maxes[:, None]).all(axis=0)
        return g[:, mask]
    g = once(size)
    generated = size
    while (g.shape[1] < size):
        fac = ((1.0 * g.shape[1]) / size)
        togen = (((size - g.shape[1]) * generated) // g.shape[1])
        g1 = once(togen)
        generated = (generated + togen)
        g = numpy.append(g, g1, axis=1)
    return g[:, :size]