statistics icon indicating copy to clipboard operation
statistics copied to clipboard

`spearman` returns NaN.

Open GregorySchwartz opened this issue 8 years ago • 6 comments

spearman should return Nothing rather than NaN:

spearman $ V.fromList [(1, 3), (5, 3)], or any case where one of the two variables is a constant.

GregorySchwartz avatar Aug 03 '17 18:08 GregorySchwartz

Good catch! Would you mind to provide fix for it?

Shimuuar avatar Aug 04 '17 06:08 Shimuuar

This would change correlation, pearson, and pearsonMatByRow to return Maybe as well. pearsonMatByRow may have issues as well if the Matrix type should have Nothing as elements rather than throwing out the entire matrix, because there is no instance for Unbox (Maybe a).

GregorySchwartz avatar Aug 04 '17 13:08 GregorySchwartz

Ohhh... It's going to be a big change. Feel free to share your opinion on the matter

Shimuuar avatar Aug 04 '17 17:08 Shimuuar

I starting to think that we should do such conversion and return Nothing when no result could be computed. We could do it incrementally and start by convertin correlation & pearson. And decide what to do with pearsonMatByRow later

Shimuuar avatar Sep 28 '17 14:09 Shimuuar

That sounds fine, but maybe return Nothing for pearsonMatByRow? The only issue is when finding bugs, it would be a tad more annoying to see which comparison is returning Nothing.

GregorySchwartz avatar Oct 02 '17 16:10 GregorySchwartz

I've started addressing this here: https://github.com/DataHaskell/statistics/tree/exceptions-not-error

ocramz avatar Jul 19 '18 22:07 ocramz