Re: correlation and NaN [message #55852] |
Wed, 19 September 2007 01:53 |
Maarten[1]
Messages: 176 Registered: November 2005
|
Senior Member |
|
|
On Sep 19, 7:08 am, WRC2...@gmail.com wrote:
> Dear,
>
> I would like to caclulate correlation factors from arrays which also
> contains NaN values. Now, i checked some newsgroups and got answers
> like this:
>
> indices =[where( finite(Var1) eq 1),where( finite(Var2) eq 1)]
> common_indices = indices(UNIQ(indices, sort(indices)))
> Result = CORRELATE( Var1(common_indices), Var2(common_indices))
>
> or with the another command (get_intersection?? - sorry, forgot the
> right name, and can find it back anymore...)
>
> The first doesn't seems to work in my case (r² = NaN), and the second
> is not recognized in my IDL 5.6 version.
> For the first method, maybe it is because one array doesn't contain a
> NaN value???
No, finite() eq 1 filters for values that are non NaN, i.e. it
captures all normal numbers.
Does this work:
common_indices = where(finite(Var1) and finite(Var2), cnt)
if cnt gt 0 then $
Rsqr = CORRELATE( Var1[common_indices], Var2[common_indices])
Maarten
|
|
|