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

Open
#23 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
julia
Domain
data

Research direction

Start in src/pca.jl at the linked validation line and trace how tpvar and tvar are computed. Reproduce the NaN case if possible, then update the handling so NaN values produce an accurate error rather than the principal-variance comparison message; done means the reported failure clearly identifies the NaN condition.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Julia
Stars
387
Forks
83
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JuliaStats/MultivariateStats.jl

All issues in JuliaStats/MultivariateStats.jl

Similar issues

More Julia issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.