[Numpy-discussion] min() of array containing NaN

Alok Singhal as8ca@virginia....
Wed Aug 13 11:52:19 CDT 2008


On 12/08/08: 18:31, Charles R Harris wrote:
>    On    Tue,   Aug   12,   2008   at   6:28   PM,   Charles   R   Harris
>    <[1]charlesr.harris@gmail.com> wrote:
>    I suppose you could use
>    min(a,b) = (abs(a - b) + a + b)/2
>    which would have that effect.
> 
>    Hmm, that is for the max, min would be
>    (a + b - |a - b|)/2

This would break when there is an overflow because of
addition/subtraction:

def new_min(a, b):
  return (a + b - abs(a-b))/2

a = 1e308
b = -1e308

new_min(a, b) # returns -inf
min(a, b)     # returns -1e308

-- 
                                           *   *          
Alok Singhal                           *           *     *
http://www.astro.virginia.edu/~as8ca/                     
                                                   *    * 


More information about the Numpy-discussion mailing list