comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Mean = NaN if NaN present
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Mean = NaN if NaN present [message #91766] Mon, 24 August 2015 16:56 Go to previous message
laura.hike is currently offline  laura.hike
Messages: 87
Registered: September 2013
Member
Hi,

I (obviously) using data with NaNs filling in for bad data. I would like to take the mean of a subset of the data and have it fail (return NaN) if any NaNs are included in the subarray. If I use

a = mean(subarray, /NaN)

this only eliminates the NaNs from the computation, meaning that a mean would be returned even if there was only one good value in the subarray. Is there any way to do this besides incorporating an IF statement before the computation, such as

if (total(finite(subarray)) eq n_elements(subarray)) then a = mean(subarray) else a = !Values.F_NAN

which is not only convoluted but may be a nuisance to implement when indices are used to define the subarray?

Thanks,

Larry
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Unable to allocate memory: to make an array. Not enough space
Next Topic: how to prevent NaNs

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:58:00 PDT 2025

Total time taken to generate the page: 0.00415 seconds