MantisBT - ITK
View Issue Details
0008893ITKpublic2009-04-16 11:002010-12-15 14:10
Bradley Lowekamp 
Luis Ibanez 
normalmajorhave not tried
closedfixed 
 
ITK-4-A3 
2010-12-15
backlog
0008893: RefactorStatistics MeanFilter and CovariantFilter may compute wrong value, no MeasurementVector AccumulateType
The precision of computing the mean and variance vary from poor to wrong, because a basic summation algorithm is used with the templated MeasurementVector as the accumulator.

The following filter may contain this bug:

itkCovarianceFilter
itkMeanFilter
itkStandardDeviationPerComponentFilter
itkWeightedCovarianceFilter
itkWeightedMeanFilter

It is likely that a AccumulateType needs to be defined in some traits for MeasurementVectors and then utilized for these algorithms.

Additional consideration needs to be made for large data sets. An improved summation algorithm such as Kahan Summation may be appropriate for these methods.

I also conjecture that likely hood that these methods are bound by main memory bandwidth and not computation, the additional over head of this type of algorithm would be minimal for most cases.

It is also possible to implement this algorithm as a new type, and wrap the detail in a class exposing just basic =,+,+=, copy, etc. operators.
No tags attached.
parent of 0011609assigned Bradley Lowekamp MeanFilter and CovariantFilter : Precision : Need Kahan Summation 
Not all the children of this issue are yet resolved or closed.
Issue History
2009-04-16 11:00Bradley LowekampNew Issue
2009-04-16 11:00Bradley LowekampAssigned To => Karthik Krishnan
2009-04-16 11:00Bradley LowekampStatusnew => assigned
2009-05-15 13:07Bradley LowekampSeverityminor => major
2010-10-21 11:20Hans JohnsonAssigned ToKarthik Krishnan => Luis Ibanez
2010-11-07 02:25Luis IbanezNote Added: 0023004
2010-12-05 11:09Luis IbanezNote Added: 0023720
2010-12-15 12:08Luis IbanezRelationship addedparent of 0011609
2010-12-15 12:11Luis IbanezNote Added: 0024173
2010-12-15 14:10Luis IbanezResolution Date => 2010-12-15
2010-12-15 14:10Luis IbanezSprint Status => backlog
2010-12-15 14:10Luis IbanezNote Added: 0024181
2010-12-15 14:10Luis IbanezStatusassigned => closed
2010-12-15 14:10Luis IbanezResolutionopen => fixed
2010-12-15 14:10Luis IbanezFixed in Version => ITK-4-A3

Notes
(0023004)
Luis Ibanez   
2010-11-07 02:25   
I had a patch for this just before we moved from CVS to Git.

It was the kind of change that "git branches" will have made very easy to manage.

will have to dig it back...
(0023720)
Luis Ibanez   
2010-12-05 11:09   
Pushed patch to Gerrit with a fix.

http://review.source.kitware.com/#change,506 [^]

This fixes the use of numeric traits (Real and Accumulate) for the internal computation of means.

The code could still benefit from addressing the issue of precision loss for very large samples, e.g. using Kahan Summation as Brad suggested.

http://en.wikipedia.org/wiki/Kahan_summation_algorithm#The_algorithm [^]
(0024173)
Luis Ibanez   
2010-12-15 12:11   
Moved the Kahan Summation to a new bug: 11609.
to be addressed separately.
(0024181)
Luis Ibanez   
2010-12-15 14:10   
http://review.source.kitware.com/#change,506 [^]
Merged