Can I use something like scipy.stats, in Python, to create a fitness function responds like a distribution -
i need create normalised fitness function positive values 0→∞. want experiment, starting (input→output) 0→0, 1→1, ∞→0. maths bit weak , expect not hard, if no how.
so output of function should heavily skewed towards 0 , need able change input value produces maximum output, 1.
i make linear function, triangular distribution, need set maximum value @ input distinguished (above value looks same.) merge 2 simple expressions this:
from matplotlib import pyplot plt import numpy np math import exp def frankenfunc(x, mu): longtail = lambda x, mu: 1 / exp((x - mu)) shortail = lambda x, mu: pow(x / mu, 2) if x < mu: return shortail(x, mu) else: return longtail(x, mu) x = np.linspace(0, 10, 300) y = [frankenfunc(i, 1) in x] plt.plot(x, y) plt.show()
this ok , should work, actual values returns don't matter used in binary tournament. still it's ugly , i'd flexibility use statistical distributions scipy or similar if possible.
so want probability dustribution pdf of form? need to:
- normalize (the integral of pdf on domain unity)
- subclass rv_continuous class shown in docs, http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.rv_continuous.html, function _pdf method.
alternatively, browse list of distributions implemented in scipy.stats. there several pdf shapes of general form you're sketching.
Comments
Post a Comment