So I have a list of data that contain both positive and negative values, and I am wondering what I have to do in order to make all the numbers positive.
|
If you are indifferent to the way your data are made positive, then check |
|||||
|
|
Assuming the list contains negative numbers, you could shift everything to the right on the number line by adding the absolute value of the smallest number plus one. This would preserve the ordering of the elements in your list.
|
|||
|
|
When you apply
Both return
Note: That also goes for other functions, like addition:
doesn't add the number
|
|||
|
|


1&/@yourlist— this just replaces all entries of your list with1, which clearly is positive. – celtschk Oct 20 '12 at 7:42Min[data]-1as0? – image_doctor Oct 20 '12 at 17:04Unprotect[Positive]; Positive[_] := True;– Rojo Oct 20 '12 at 18:00