Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Min function returns Min[2.05875,] instead of just 2.05875

2 views
Skip to first unread message

dg

unread,
Jun 1, 2009, 7:12:40 AM6/1/09
to
I have an matrix "data" with 17x248 real numbers.

When I enter Min[data], I get
Min[2.05875, ] as a result, instead of just the number 2.05875.

This is Mathematica 7.0.1 on Mac OS X.

Why?

How can I get just the number from the result?

TIA

dr DanW

unread,
Jun 2, 2009, 6:38:07 AM6/2/09
to
This is just a guess, but you may have an invisible character as an
element in your matrix that is being interpreted as a symbol. The
second argument of the Min is in your matrix somewhere. Do a FullForm
on the output to see what the second argument to Min is, then
eliminate it from your matrix.

Sjoerd C. de Vries

unread,
Jun 2, 2009, 6:40:47 AM6/2/09
to
This is precisely the result you get if one of the matrix entries
contains an empty string (""). I'd check my data for this if I were
you.

Cheers -- Sjoerd

Francesco

unread,
Jun 2, 2009, 6:41:21 AM6/2/09
to
Non numerical entry after the comma.
-Francesco

Jens-Peer Kuska

unread,
Jun 2, 2009, 6:41:53 AM6/2/09
to
Hi,

can you explain what the minimum of a set of
vectors with dimension 248 is ?

Or do you mean Min[Flatten[data]] ?

Regards
Jens

Szabolcs

unread,
Jun 2, 2009, 6:42:35 AM6/2/09
to
On Jun 1, 2:12 pm, dg <davide....@gmail.com> wrote:
> I have an matrix "data" with 17x248 real numbers.
>
> When I enter Min[data], I get
> Min[2.05875, ] as a result, instead of just the number 2.05875.
>
> This is Mathematica 7.0.1 on Mac OS X.
>
> Why?
>

You typed Min[data,] instead of Min[data].

> How can I get just the number from the result?
>

Remove the comma.

Christopher Henrich

unread,
Jun 2, 2009, 6:43:07 AM6/2/09
to
In article <h00d38$pkq$1...@smc.vnet.net>, dg <davide....@gmail.com>
wrote:

I think you have a non-printing character in your matrix.
Min[2,3,4,5,x] reduces to Min[2,x]. But if the "x" was something so
strange that Mathematica did not have a way of printing it, then I think
we would see Min[2,].

If "data" is stored as a list of 17 row, each of which should contain
248 numbers, then look for a row with Length[row] = 249.

--
Christopher J. Henrich
chen...@monmouth.com
http://www.mathinteract.com
"A bad analogy is like a leaky screwdriver." -- Boon

pfalloon

unread,
Jun 2, 2009, 6:43:28 AM6/2/09
to

Hi,
It's hard to see exactly what's going wrong because you have not
included the exact code, but at a guess I'd say there may some
invisible wrapper around the list of numbers, which is preventing Min
evaluating properly.

In general, the behaviour should be as follows:

In[290]:= data = RandomReal[10, {17, 248}];

Min[data]
Out[291]= 0.00017248

Cheers,
Peter.

Bill Rowe

unread,
Jun 2, 2009, 6:44:00 AM6/2/09
to
On 6/1/09 at 7:12 AM, davide....@gmail.com (dg) wrote:

>I have an matrix "data" with 17x248 real numbers.

>When I enter Min[data], I get Min[2.05875, ] as a result, instead
>of just the number 2.05875.

>This is Mathematica 7.0.1 on Mac OS X.

>Why?

There is at least one entry in your matrix that does not have a
numeric value. Quite likely, this is a Null. This can happen
when you read data in from a CSV file using Import and there is
an extra comma somewhere.

You can verify this to be the case by doing

Union[Head/@Flatten[data]]

>How can I get just the number from the result?

Obviously, the best choice would be to fix the problem of a
non-numeric entry. However, the numeric value can be extracted
in a number of ways such as

In[2]:= Cases[List @@ Min[2.05875,], _?NumericQ][[1]]

Out[2]= 2.05875


dg

unread,
Jun 2, 2009, 6:45:06 AM6/2/09
to
Solution: The matrix had missing values.

This will work in such cases:
Min[Cases[data // Flatten, _?NumericQ]]

Thanks to a helpful person that found this solution.

Murray Eisenberg

unread,
Jun 3, 2009, 1:09:26 AM6/3/09
to
Min flattens lists!

Jens-Peer Kuska wrote:
> Hi,
>
> can you explain what the minimum of a set of
> vectors with dimension 248 is ?
>
> Or do you mean Min[Flatten[data]] ?
>
> Regards
> Jens
>
> dg wrote:

--
Murray Eisenberg mur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

Bob Hanlon

unread,
Jun 3, 2009, 1:11:57 AM6/3/09
to

Min[{{a, b, c}, {d, e, f}, {g, h, i}}]

min(a,b,c,d,e,f,g,h,i)

Min[{{a, {b, j}, c}, {d, e, f}, {g, h, {i, k}}}]

min(a,b,c,d,e,f,g,h,i,j,k)

Min will flatten its argument.

Attributes[Min]

{Flat,NumericFunction,OneIdentity,Orderless,Protected,ReadProtected}


Bob Hanlon


---- Jens-Peer Kuska <ku...@informatik.uni-leipzig.de> wrote:

=============

0 new messages