def importanceMixing(oldpoints, oldpdf, newpdf, newdistr, forcedRefresh = 0.01):
    reuseindices = []
    batch = len(oldpoints)
    for i, sample in enumerate(oldpoints):
        r = uniform(0, 1)
        if r < (1-forcedRefresh) * newpdf(sample) / oldpdf(sample):
            reuseindices.append(i)
        # never use only old samples
        if batch - len(reuseindices) <= max(1, batch * forcedRefresh):
            break
    newpoints = []
    # add the remaining ones
    while len(reuseindices)+len(newpoints) < batch:
        r = uniform(0, 1)
        sample = newdistr()
        if r < forcedRefresh:
            newpoints.append(sample)
        else:
            if r < 1 - oldpdf(sample)/newpdf(sample):
                newpoints.append(sample)
    return reuseindices, newpoints
Implements importance mixing. Given a set of points, an old and a new pdf-function for them
dataset/ETHPy150Open pybrain/pybrain/pybrain/auxiliary/importancemixing.py/importanceMixing