[Numpy-discussion] Combining Sigmoid Curves

Rich Shepard rshepard at appl-ecosys.com
Fri May 2 18:20:31 EDT 2008


On Fri, 2 May 2008, Anne Archibald wrote:

> It's better not to work point-by-point, appending things, when working
> with numpy. Ideally you could find a formula which just produced the right
> curve, and then you'd apply it to the input vector and get the output
> vector all at once.

Anne,

   That's been my goal. :-)

> How about using the cosine?
>
> def f(left, right, x):
>    scaled_x = (x-(right+left)/2)/((right-left)/2)
>    return (1+np.cos((np.pi/2) * scaled_x))/2
>
> exactly zero at both endpoints, exactly one at the midpoint,
> inflection points midway between, where the value is 1/2. If you want
> to normalize it so that the area underneath is one, that's easy to do.

> More generally, the trick of producing a scaled_x as above lets you
> move any function anywhere you like.

   This looks like a pragmatic solution. When I print scaled_x (using left =
0.0 and right = 100.0), the values range from -1.0 to +0.998. So, I need to
figure out the scale_x that sets the end points at 0 and 100.

Thanks very much,

Rich



More information about the NumPy-Discussion mailing list