JuliaStats / MultivariateStats.jl

A Julia package for multivariate statistics and data analysis (e.g. dimension reduction)
Other
376 stars 86 forks source link

ArgumentError: principal variance cannot exceed total variance. NaN > NaN #23

Open oxinabox opened 8 years ago

oxinabox commented 8 years ago

So I am debugging some mean code that seems to be sending values right to the exteme ends of the Float32 range.

I kept getting ArgumentError: principal variance cannot exceed total variance on this line

So I enhanced it to be more informative on my local copy:

tpvar <= tvar || isapprox(tpvar,tvar) || throw(ArgumentError("principal variance cannot exceed total variance. $tpvar > $tvar"))

And I found out that both tpvar and tvar ended up at NaN. Now how this happens is unknown to me (right now, but soon I will know, I hope).

But my point here is that this is the wrong error message. I suggest a NaN check should be added.

andreasnoack commented 8 years ago

Showing the values would be helpful. It would great if you could open a PR with your change.