octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #48774] Functions for moving statistics


From: Juan Pablo Carbajal
Subject: [Octave-bug-tracker] [bug #48774] Functions for moving statistics
Date: Tue, 18 Dec 2018 16:41:24 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0

Follow-up Comment #16, bug #48774 (project octave):

Hi Rik,

I see... the issue is that in the assumptions of the code mean is not a
function returning a multidimensional outpout. It applies it self over
multiple input dimension, but the calculation itself is a scalar. 
'outdim' is used when the function itself goes form R^m --> R^D, it is meant
to select one of the D dimensions of the output.

I agree that in the general matlab/octave jargon this is not directly
interpreted like this. That is, one would be lead to think that mean has a
multidim output because when you apply it to a multidim input it keeps the
other dimensions it doesn't act upon, e.g. size(x) == [5 10 2], then size
(mean (x)) == [1 10 2] (or that squeezed). But the calculation itself is from
R^m (set of scalars) to a R (a scalar), so the function is a scalar function.

This is why movfun is telling you that mean doesn't returns the 3rd dimension,
which you are asking for.

If we can discuss this a little further, I will be glad so I can get an idea
how to put it in more clear terms in the docs.

On the internal working, movfun puts the desired dimension as the first
dimension of a new array (permute) and then join all other dimension as
columns (reshape). This is why the function is asked to work on columns, and
not on multidimensional arrays.

The idea behind this convention is to allow the user to think only on the
atomic behavior of their function (how it behaves when you give a column
vector to it), and not on its behavior for multidimensional arrays.

Try this example, as an illustration

x = magic (3);
x(:,:,2) = 3*x
y = movfun (@statistics, x, 3, 'outdim', 6); % returns movmean
y_ = movmean (x, 3);
assert(y,y_)


When statistics is presented with a column vector it returns a vector with 9
elements (a 9-dimensional output), we choose the 6th one. The function mean,
when aplied to a column vector returns a scalar, hence you can't choose the
3rd dimension.

I hope this clarifies some thing.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?48774>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]