0

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()

Franken function output

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.

Peter Shannon
  • 191
  • 1
  • 3

1 Answers1

0

So you want a probability dustribution with a pdf of this form? Then you need to:

Alternatively, browse the list of distributions implemented in scipy.stats. there are several with pdf shapes of this general form you're sketching.

ev-br
  • 24,968
  • 9
  • 65
  • 78