Re: Re: Setting Negatives to Zero

*To*: mathgroup at smc.vnet.net*Subject*: [mg82850] Re: [mg82803] Re: [mg82736] Setting Negatives to Zero*From*: János <janos.lobb at yale.edu>*Date*: Thu, 1 Nov 2007 05:16:12 -0500 (EST)*References*: <7189487.1193744482274.JavaMail.root@m35> <op.t00vb4u2qu6oor@monster.gateway.2wire.net> <18551847.1193774194904.JavaMail.root@m35> <200710311115.GAA22532@smc.vnet.net>

It does not work in 5.2, unless I Map it to the list at Level {2}. Like Map[Clip[#,{0,Max[lst]}]&,lst, {2}] or something similar. J=E1nos On Oct 31, 2007, at 7:15 AM, DrMajorBob wrote: > But Clip isn't Listable! > > Attributes@Clip > > {NumericFunction, Protected} > > So how could that work? But it does, evidently: > > Clip[Range@100, {5, 95}] > > {5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, \ > 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, \ > 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, \ > 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, \ > 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, \ > 88, 89, 90, 91, 92, 93, 94, 95, 95, 95, 95, 95, 95} > > Yet another undocumented feature. > > Bobby > > On Tue, 30 Oct 2007 14:54:09 -0500, Kevin J. McCann > <Kevin.McCann at umbc.edu> wrote: > >> Thanks, Bobby. >> >> Carl Woll gave me the following way to do it. >> >> Clip[data,{0,Infinity}] >> >> It works and is fast. I had never used Clip before - actually, I >> didn't >> know about it. >> >> Kevin >> >> DrMajorBob wrote: >>> data = data /. x_?Negative -> 0 >>> >>> or something like >>> >>> Attributes[negToZero]={Listable} >>> negToZero[x_?NumericQ] = Sign[x] x >>> data = negToZero@data >>> >>> Bobby >>> >>> On Tue, 30 Oct 2007 03:26:37 -0500, Kevin J. McCann >>> <Kevin.McCann at umbc.edu> wrote: >>> >>>> I have a very large data set (64000 x 583) in which negative values >>>> indicate "no data", unfortunately these negatives are not all >>>> the same. >>>> I would like to efficiently set all these negatives to zero. I know >>>> that >>>> I will likely be embarrassed when I see how to do it, but I >>>> can't seem >>>> to remember or figure it out. I should emphasize that because of = >>>> the >>>> size of the data set, this needs to be done efficiently. Another >>>> programming language does it as follows: >>>> >>>> x(x < 0) = 0; >>>> >>>> Thanks, >>>> >>>> Kevin >>> >>> >>> >> > > > > -- > > DrMajorBob at bigfoot.com ---------------------------------------------- Trying to argue with a politician is like lifting up the head of a corpse. (S. Lem: His Master Voice)