def sample(self, nsample, random_state=None):
    if (random_state is None):
        random_state = numpy.random

    def once(size):
        X = self.models[0].sample(size, random_state)
        nf = X.shape[(- 1)]
        lnprob = sum([model.score(X) for model in self.models[1:]])
        prob = numpy.exp(lnprob)
        prob /= prob.max()
        keep = (random_state.rand(len(X)) < prob)
        return X[keep].reshape((- 1), nf)
    g = once(nsample)
    ng = nsample
    while (len(g) < nsample):
        togen = (((nsample - len(g)) * ng) // len(g))
        g1 = once(togen)
        ng = (ng + togen)
        g = numpy.append(g, g1, axis=0)
    return g[:nsample]
def sample(self, nsample, random_state=None):
    if (random_state is None):
        random_state = numpy.random

    def once(size):
        X = self.models[0].sample(size, random_state)
        nf = X.shape[(- 1)]
        lnprob = sum([model.score(X) for model in self.models[1:]])
        prob = numpy.exp(lnprob)
        prob /= prob.max()
        keep = (random_state.rand(len(X)) < prob)
        return X[keep].reshape((- 1), nf)
    g = once(nsample)
    ng = nsample
    while (len(g) < nsample):
        togen = (((nsample - len(g)) * ng) // len(g))
        g1 = once(togen)
        ng = (ng + togen)
        g = numpy.append(g, g1, axis=0)
    return g[:nsample]