I created this Python function to generate a sigmoid function where I can modify position and width:
import numpy as np import matplotlib.pyplot as plt def sigmoid(x,a,b): # sigmoid function with parameters a = center; b = width return 1/(1+np.exp(-(x-a)/b))
For example changing the parameter b I can make it wider or narrower:
# testing changing sigmoid width (and slope at the same time) - parameter b x = np.linspace(0,10,256) y = sigmoid(x,5,1) # default ymax = sigmoid(x,5,1.75) ymin = sigmoid(x,5,0.25) # Create the plot plt.plot(x,y,lw=2,color='black') plt.plot(x,ymax,lw=2,color='green') plt.plot(x,ymin,lw=2,color='orange')
The above is fairly straightforward.
But what if I wanted a rotated sigmoid function? I simulated my intended result "graphically" in the figure below:
which I plotted by just creating a new independent variable x ('test' variable below) and swapping x and y:
Is there a way to achieve this shape with a new sigmoid-like function, or to rotate the original?
It has occurred to me that I could use something like
-np.sinh(x) but what I'd really like is to have a similar exponential expression with parameters a and b to control the curve's shape.
This question is also posted on Stack Overflow https://stackoverflow.com/questions/25851287/how-to-generate-a-rotated-by-90-degrees-logistic-sigmoid-function-in-python