Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum > General > > "Calculate number of occurences in tha table"

Post Reply:
Name:
Email Address:

Please send email when my message is replied to.

Url (optional):
Subject:
Message: view original message?
Attachment (optional):
Please answer this:4+3 =



Original Message (ID '238012') By yehuda:
In Response To 'Re: Calculate number of occurences in tha table' --------- Count is good for counting patterns For large matrices it is much more efficient to use Tally here are the results for a 1000X1000 matrix f[n_] := Count[Flatten[bigT], n] bigT = RandomInteger[10, {1000, 1000}]; Timing[Table[{n,f[n]},{n,0,10}];]/Timing[Tally[Flatten@bigT]; (Timing[Table[{n, f[n]}, {n, 0, 10}];]/ Timing[Tally[Flatten@bigT];])[[1]] resulting with a factor of more than 60 time faster. Part of it is the need to flatten the matrix for each new value. Modifying it for a single flattening reduces this to a factor of 58 so, for big data arrays / matrices and alike it is wiser to use Tally Count is more flexible, but less efficient yehuda