Group Abstract Group Abstract

Message Boards Message Boards

2
|
4.4K Views
|
6 Replies
|
5 Total Likes
View groups...
Share
Share this post:

MinMax behaviour compared to Min and Max

Mathematica (Wolfram Language) was designed that:

Min[]

gives Infinity and that

Max[]

gives -Infinity. This is chosen in such a way that (e.g.):

Min[Min[], 3, 4]

will not be influenced by the Min[] argument, and thus results nicely in 3.

In the implemented of MinMax it says: MinMax[list] gives the list {Min[list],Max[list]}.

However it also says: MinMax[{}] gives {-Infinity,Infinity}. Which contrasts each other!

data={};
MinMax[data]
{Min[data],Max[data]}

returning:

{-\[Infinity], \[Infinity]}
{\[Infinity], -\[Infinity]}

The exact opposite! I would consider this either a design flaw or a bug. The choice of returning {-\[Infinity], \[Infinity]} is not in line with other definitions.

POSTED BY: Sander Huisman
6 Replies

Thank you for bringing this to our attention.

@Moderation Team @Stefan Ragnarsson Thanks for taking care! Is this paclet-updateable? Or is this deeper?

POSTED BY: Sander Huisman

I don't think this can be updated via a paclet.

@Stefan Ragnarsson I stand corrected for my last example should not work (i removed it from my post), even when the MinMax[{}] is fixed, as it flattens the list:

MinMax[{1, 2, 3, MinMax[{-4, 1.2}], MinMax[{}]}]

Would simplify to:

    MinMax[{1, 2, 3, {-4, 1.2}, {inf,-inf}}]
    MinMax[{1, 2, 3, -4, 1.2, inf,-inf}]
    MinMax[{-inf,inf}]

So my example is bad... sorry for that! But I still think the output of MinMax[{}] should be reversed.

POSTED BY: Sander Huisman

Thank you, it was brought to the attention our teams.

POSTED BY: EDITORIAL BOARD

O btw, I found out because I generate many lists (with different lengths) and I want to track the Min and Max without storing all the data. So I update my Min and Max bounds every time a new list is generated. However some lists have zero length, and then my bounds are a mess. So I have to go back to my own Min/Max:

Through[{Min,Max}[#]&
POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard