Most times, you don't want this test to return true indeed. Imagine testinga==b and having atrue result when botha andb are undefined; this would make little sense. It is the same withNaN.
While it is not the original question, note that you can test equality assumingNaN 's are equal:
But with that you usually want to test if "behaviors" are the same (and not equality per se), e.g. if two functions return the same number or bothNaNdo something, elsedo something else.
Like that, each value of "a" is correlated to each value of "b", but applying the formula of the correlation, the correlation of two single numbers is NaN. To compute the correlation correctly, traspose the input vectors
Best Answer