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
Re: Mean = NaN if NaN present [message #91778 is a reply to message #91766] Tue, 25 August 2015 07:08 Go to previous messageGo to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Monday, August 24, 2015 at 6:56:04 PM UTC-5, LMH wrote:
> 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

Don't you just want MEAN without the /NAN flag?

-Jeremy.
[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:36:14 PDT 2025

Total time taken to generate the page: 0.00481 seconds