On 04/28/11 23:17, Muhali wrote:
On 04/28/11 13:49, Thomas Weber wrote:
On Tue, Apr 19, 2011 at 02:26:07PM -0700, Muhali wrote:
I guess the subject says it all.

It seems you didn't receive an answer for 2 weeks, so I guess nobody
understood what you wanted to ask -- I know that I don't have a clue and
frankly, my time is too limited to start guessing ...

ok, so let me clarify:

There is no function nancumsum in package nan. This function should compute the 
cumulative sum of arrays just like cumsum, only that it respects nan values. 
This is easily done in a script, but I guess a builtin function (like cumsum) 
is faster.

Does that make sense?


The request make some sense to me, although I was reluctant to include it in the NaN-toolbox for the following reasons: (1) Skipping NaNs makes perfect sense in all statistical functions, but is not clear whether the same is true for non-statistical (i.e. deterministic) methods. Moreover, if the principle of "skipping NaN's" is applied, than the resulting vector will be shortened; and what should happen in case of a matrix, where each vector contains a different number of NaN's ?

In other words, the trivial approach
  function y=nancumsum(x) x(isnan(x))=0; y=cumsum(x); end;
does not make sense. A possible solution would be that
  cumsum([1,2,NaN,1])
results in
  [1,3,NaN,4]

At least, if the function is used to estimate a cumulative distribution function, the result could be still useful. I'm not sure, this is what Muhali and others want, but it would be an improvement of the current cumsum function.

(2) the proliferation of two versions for the same job (e.g. mean and nanmean) is more complicated than necessary for users; the NaN-toolbox tries to reduce the proliferation of these duplicated functions. So, it would be desirable to have just one cumsum function that does the "right" thing. However, since cumsum is a built-in function, it can not be simply replaced by a new m-file.

So, do you have any suggestions how this issues should be addressed ?
Answering this question myself, I've included the attached cumsumskipnan function in the NaN-toolbox. Eventually, a mex-version will replace it for performance reasons.


Kind regards,
    Alois













M.

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today.  Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Attachment: cumsumskipnan.m
Description: Mathematica Notebook document

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to