I need to create a normalised fitness function for positive values 0→∞. I want to experiment, starting with (input→output) something like 0→0, 1→1, ∞→0. My maths is a bit weak and expect this is really not hard, if you no how.
So the output of the function should be heavily skewed towards 0 and I need to be able to change the input value which produces the maximum output, 1.
I could make a linear function, something like a triangular distribution, but then I need to set a maximum value at which input would be distinguished (above that value everything looks the same.) I could also merge two simple expressions together with something like this:
from matplotlib import pyplot as plt
import numpy as np
from 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) for i in x]
plt.plot(x, y)
plt.show()
This is ok and should work, especially as the actual values it returns don't matter too much as they will be used in a binary tournament. Still it's ugly and I'd like the flexibility to use the statistical distributions from scipy or something similar if possible.