Closed gdevenyi closed 6 years ago
Seems like this is caused by cancellation when calculating the variance . It only seems likely to become an issue in volumes that are uniform and close to 1, since the Sum^2
is close to Sum * Sum / #voxels
, which might explain why the bug went unnoticed for so long.
See: https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Na%C3%AFve_algorithm
I'll work on fixing this using value shifting like suggested in the wiki article.
Wow, this is the second naive numerical implementation I've run into this month :)
Thanks for looking into this!
Indeed a good catch! In my defense when I wrote mincstats (circa 2002) that wikipedia page looked a lot different! :)
We'll overlook it this time @andrewjanke, but you're on thin ice as far as bugs in the 100+ minctools you wrote from scratch.... ;)
Solved by #83
Looking at the ratio of two files generated by minccalc like this that are very very similar:
Computing statistics on the ratio, mincstats breaks down: