[Numpy-discussion] Combining Sigmoid Curves
Rich Shepard
rshepard@appl-ecosys....
Fri May 2 15:32:09 CDT 2008
On Fri, 2 May 2008, Christopher Barker wrote:
> this could use some serious vectorization/numpyification! Poke around the
> scipy Wiki and whatever other tutorials you can find -- you'll be glad you
> did. A hint:
>
> When you are writing a loop like:
>> for i in xL:
>> x.append(xL[i])
>
> You should be doing array operations!
Chris,
Good suggestions. I need to append the two numpy arrays so I return all x
values in a single list and all y values in another list. I'll read the
numpy book again.
> That's why you get this error:
> TypeError: unsupported operand type(s) for -: 'list' and 'float'
>
> you're trying to do array operations on a list.
Ah, so!
> Also, you probably want np.linspace, rather than arange, it's a better
> option for floats.
arange() has worked just fine in other functions.
> # now put them together:
> x = np.hstack((xL, xR[1:])) # don't want to duplicate the midpoint
> y = np.hstack((yL, yR[1:]))
> Also, you don't need to create the separate left and right arraysand put
> them together, slicing gives a view, so you could do:
I assume that there's a way to mate the two curves in a single equation.
I've not been able to find what that is.
Thanks,
Rich
More information about the Numpy-discussion
mailing list