Dekryptor / aforge

Automatically exported from code.google.com/p/aforge
Other
0 stars 0 forks source link

Mode function for Aforge.Math Statistics class #180

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
New static method in Statistics class to calculate mode of integer array. 
Attached is a patch for the Statistics class and a new unit test class for 
Math.Tests

Original issue reported on code.google.com by kyle.par...@gmail.com on 28 Dec 2010 at 6:33

Attachments:

GoogleCodeExporter commented 8 years ago
Implementation of Mode function is wrong. Here is what Mode means:
http://en.wikipedia.org/wiki/Mode_(statistics)

The problem is that you missed the key of that class. Here is comment you've 
copy-pasted, but ignored:
"The input array is treated as histogram, i.e. its indexes are treated as 
values of stochastic function, but array values are treated as "probabilities" 
(total amount of hits)".

What you did is valid for a regular array, but not for histogram. If we have 
histogram like this:
{ 1, 1, 2, 3, 6, 8, 11, 12, 7, 3 };
, then Mode=7, not 1 as you've wrote in the comment. The max number in this 
array is 12, which is the number of hits for value 7 – most frequent value.

Question: What is the supposed output if we have bimodal or multimodal 
histogram? Maximum most frequent number? If so, it must be documented.

Original comment by andrew.k...@gmail.com on 3 Jan 2011 at 4:56

GoogleCodeExporter commented 8 years ago
Attached is the corrected (hopefully) version of the mode function, and revised 
unit tests. 

Original comment by kyle.par...@gmail.com on 3 Mar 2011 at 1:48

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by andrew.k...@gmail.com on 19 Apr 2011 at 8:57

GoogleCodeExporter commented 8 years ago

Original comment by andrew.k...@gmail.com on 5 May 2011 at 12:32

GoogleCodeExporter commented 8 years ago
Added AForge.Math.Statistics.Mode() method to calculate mode value of the 
specified histogram array.

Committed in revision 1458. Will be released in version 2.2.0.

Original comment by andrew.k...@gmail.com on 6 May 2011 at 3:19

GoogleCodeExporter commented 8 years ago

Original comment by andrew.k...@gmail.com on 28 Jul 2011 at 9:44

GoogleCodeExporter commented 8 years ago

Original comment by andrew.k...@gmail.com on 10 Aug 2011 at 9:24