[Numpy-discussion] Piecewise functions.

Andrea Riciputi ariciputi at pito.com
Thu Sep 22 08:47:01 EDT 2005


Hi all,
this is probably an already discussed problem, but I've not been able  
to find a solution even after googling a lot.

I've a piecewise defined function:

        /
        | f1(x)    if x <= a
f(x) = |
        | f2(x)    if x > a
        \

where f1 and f2 are not defined outside the above range. How can I  
define such a function in Python in order to apply (map) it to an  
array ranging from values smaller to values bigger than a?

Thanks,
  Andrea.




More information about the NumPy-Discussion mailing list