def testnes():
    from pybrain.optimization.distributionbased.xnes import XNES
    from scipy import ones
    from random import gauss    
    import pylab  
    noise = 0.1
    x0 = ones(5)
    fun = lambda x: -sum(x**2) - gauss(0,noise)
    
    fun2 = AdaptiveResampler(fun, 10)
    l = XNES(fun, x0, maxEvaluations=1100, storeAllEvaluations=True)
    res = l.learn()
    print((sum(res[0]**2) ))
    pylab.plot(list(map(abs, l._allEvaluations)))
    
    l2 = XNES(fun2, x0, maxEvaluations=1100, storeAllEvaluations=True)
    res = l2.learn()
    print((sum(res[0]**2) ))
    print((fun2.resample_over))
    pylab.plot(list(map(abs,l2._allEvaluations)))
    pylab.semilogy()
    pylab.show()
dataset/ETHPy150Open pybrain/pybrain/pybrain/tools/aptativeresampling.py/testnes/original