[Numpy-discussion] Combining Sigmoid Curves
Fri May 2 15:07:23 CDT 2008
2008/5/2 Rich Shepard <email@example.com>:
> When I last visited I was given excellent advice about Gaussian and other
> bell-shaped curves. Upon further reflection I realized that the Gaussian
> curves will not do; the curve does need to have y=0.0 at each end.
> I tried to apply a Beta distribution, but I cannot correlate the alpha and
> beta parameters with the curve characteristics that I have.
> What will work (I call it a pi curve) is a matched pair of sigmoid curves,
> the ascending curve on the left and the descending curve on the right. Using
> the Boltzmann function for these I can calculate and plot each individually,
> but I'm having difficulty in appending the x and y values across the entire
> range. This is where I would appreciate your assistance.
> The curve parameters passed to the function are the left end, right end,
> and midpoint. The inflection point (where y = 0.5) is half-way between the
> ends and the midpoint.
> What I have in the function is this:
> def piCurve(ll, lr, mid):
> flexL = (mid - ll)/2.0
> flexR = (lr - mid)/2.0
> tau = (mid - ll)/10.0
> x = 
> y = 
> xL = nx.arange(ll,mid,0.1)
> for i in xL:
> yL = 1.0 / (1.0 + nx.exp(-(xL-flexL)/tau))
> for j in yL:
> xR = nx.arange(mid,lr,0.1)
> for i in xR:
> yR = 1 - (1.0 / (1.0 + nx.exp(-(xR-flexR)/tau)))
> for j in yR:
> appData.plotX = x
> appData.plotY = y
> Python complains about adding to the list:
> yL = 1.0 / (1.0 + nx.exp(-(x-flexL)/tau))
> TypeError: unsupported operand type(s) for -: 'list' and 'float'
> What is the appropriate way to generate two sigmoid curves so that the x
> values range from the left end to the right end and the y values rise from
> 0.0 to 1.0 at the midpoint, then lower to 0.0 again?
How about multiplying two Boltzmann terms together, ala:
f(x) = 1/(1+exp(-(x-flex1)/tau1)) * 1/(1+exp((x-flex2)/tau2))
You'll find if your two flexion points get too close together, the
peak will drop below the maximum for each individual curve, but the
transition will be continuous.
AJC McMorland, PhD candidate
Physiology, University of Auckland
(Nearly) post-doctoral research fellow
Neurobiology, University of Pittsburgh
More information about the Numpy-discussion