Back to the main page.
Bug 1535 - Nanvar gives inaccurate results
Status | CLOSED FIXED |
Reported | 2012-06-18 13:43:00 +0200 |
Modified | 2019-08-10 11:55:44 +0200 |
Product: | FieldTrip |
Component: | core |
Version: | unspecified |
Hardware: | PC |
Operating System: | Windows |
Importance: | P3 normal |
Assigned to: | |
URL: | |
Tags: | |
Depends on: | |
Blocks: | |
See also: |
Boris Reuderink - 2012-06-18 13:43:13 +0200
While writing unit-test for nansum, nanmean, nanvar and nanstd (see bug #1398), I found a problem in nanvar: --- >> x = rand(10000, 1); >> for i = logspace(4, 12, 6); v1 = var(x + i); v2 = nanvar(x + i); fprintf('offset: %.2g, \tvar: %.2f, \tnanvar: %.2f \n', i, v1, v2); end; --- resulting in: --- offset: 1e+004, var: 0.08, nanvar: 0.08 offset: 4e+005, var: 0.08, nanvar: 0.08 offset: 1.6e+007, var: 0.08, nanvar: 2.00 offset: 6.3e+008, var: 0.08, nanvar: -2883.87 offset: 2.5e+010, var: 0.08, nanvar: 3328932.55 offset: 1e+012, var: 0.09, nanvar: 96326851278.31 --- This is with FieldTrip's nanvar function. The nanvar variant in MATLAB's statistics toolbox gives the same variance as 'var' does. Note that these get inaccurate as well for offsets > 1e12. Some background information can be found on: http://www.johndcook.com/blog/2008/09/26/comparing-three-methods-of-computing-standard-deviation/
Boris Reuderink - 2012-09-28 14:54:53 +0200
Fixed in #1398.
Boris Reuderink - 2012-11-02 13:29:53 +0100
I am no longer working on FieldTrip. Hence, I donate all my bugs to the joint development user.
Robert Oostenveld - 2019-08-10 11:51:47 +0200
This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue describing the issue on https://github.com/fieldtrip/fieldtrip/issues.