Re: movfun

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: movfun

Rik-4
On 12/10/2018 09:00 AM, [hidden email] wrote:
Subject:
[movfun] moving window function: matlab
From:
Juan Pablo Carbajal [hidden email]
Date:
12/10/2018 03:56 AM
To:
Maintainers GNU Octave [hidden email]
List-Post:
[hidden email]
Precedence:
list
MIME-Version:
1.0
Message-ID:
[hidden email]
Content-Type:
text/plain; charset="UTF-8"
Message:
1

Hi all,

I think movfun [1] is in good shape. To implement the matlab functions
(just wrappers around movfun) I need to know the lest of mov*
functions shipped with matlab (are there more thna in savannah? [2])

Can any one get this list? I guess by TAB completion

They have a list in the documentation (https://www.mathworks.com/help/matlab/referencelist.html?type=function&s_cid=doc_ftr&listtype=alpha#section_M)

movmad    Moving median absolute deviation
movmax    Moving maximum
movmean    Moving mean
movmedian    Moving median
movmin    Moving minimum
movprod    Moving product
movstd    Moving standard deviation
movsum    Moving sum
movvar    Moving variance

I think movfun.m should be transferred in to Mercurial in to scripts/statistics/private as it is a helper function for the visible functions above.

--Rik


Reply | Threaded
Open this post in threaded view
|

Re: movfun

Juan Pablo Carbajal-2
> I think movfun.m should be transferred in to Mercurial in to scripts/statistics/private as it is a helper function for the visible functions above.
>
> --Rik
>
Hi Rik,
Thanks for the list, I can write the wrappers.

I strongly disagree about movfun (and movslice) as private functions.
For me the the actually valuable contributions to octave are movfuin
and movslice. Also those are the functions I use in my work (the ones
form matlab are just simple calls to movfun).
If the community decision  is to make movfun private, then I will not
make anymore the effort to comply with the sometimes tedious octave
coding style and keep development outside octave. That is, the burden
of maintenance will 100% to the ones who decided to make it private,
and we will have diverging movfun in the environment.

Regards,

Reply | Threaded
Open this post in threaded view
|

Re: movfun

Rik-4
On 12/11/2018 06:41 PM, Juan Pablo Carbajal wrote:

>> I think movfun.m should be transferred in to Mercurial in to scripts/statistics/private as it is a helper function for the visible functions above.
>>
>> --Rik
>>
> Hi Rik,
> Thanks for the list, I can write the wrappers.
>
> I strongly disagree about movfun (and movslice) as private functions.
> For me the the actually valuable contributions to octave are movfuin
> and movslice. Also those are the functions I use in my work (the ones
> form matlab are just simple calls to movfun).
> If the community decision  is to make movfun private, then I will not
> make anymore the effort to comply with the sometimes tedious octave
> coding style and keep development outside octave. That is, the burden
> of maintenance will 100% to the ones who decided to make it private,
> and we will have diverging movfun in the environment.

I assumed it should be private because it was only being used by the movXXX
functions.

What is an example use case where some other functions would want to call
movfun or movslice?

--Rik



Reply | Threaded
Open this post in threaded view
|

Re: movfun

Juan Pablo Carbajal-2
On Wed, Dec 12, 2018 at 5:11 AM Rik <[hidden email]> wrote:

>
> On 12/11/2018 06:41 PM, Juan Pablo Carbajal wrote:
> >> I think movfun.m should be transferred in to Mercurial in to scripts/statistics/private as it is a helper function for the visible functions above.
> >>
> >> --Rik
> >>
> > Hi Rik,
> > Thanks for the list, I can write the wrappers.
> >
> > I strongly disagree about movfun (and movslice) as private functions.
> > For me the the actually valuable contributions to octave are movfuin
> > and movslice. Also those are the functions I use in my work (the ones
> > form matlab are just simple calls to movfun).
> > If the community decision  is to make movfun private, then I will not
> > make anymore the effort to comply with the sometimes tedious octave
> > coding style and keep development outside octave. That is, the burden
> > of maintenance will 100% to the ones who decided to make it private,
> > and we will have diverging movfun in the environment.
>
> I assumed it should be private because it was only being used by the movXXX
> functions.
>
> What is an example use case where some other functions would want to call
> movfun or movslice?
>
> --Rik
>
>

Hi Rik,

Many are in the demo section of movfun. But in general any function
that is not in the ones provided by matlab, e.g. user functions. Lets
say you want a quantile on a moving window of size 9, there is no
mov*.m for that in matlab's repertoire, with movfun it is just q =
movfun (@(x)quantile(x, 0.15), X, 9)

I have just pushed the latest changes which allow to use functions
with multidimensional output here the code of the demo

%!demo
%! N    = 1e3;
%! wlen = 99;
%! x  = linspace (-1, 1, N).';
%! pp = [-2 0 1 0];
%! y  = polyval (pp, x);
%! yn = y + 0.1 * (abs (y) + 0.5) .* exp (randn (N, 1));
%!
%! st = movfun (@(y)statistics(y).', yn, wlen);
%! figure (), clf
%!    h = plot (x, y, '-',
%!              x, yn, '.',
%!              x, st(:,[3 6]), '-',
%!              x, st(:,6) + [-1 1].*st(:,7), '-',
%!              x, st(:,[1 2 4 5]), '-');
%!    set (h([1 3:4]), 'linewidth', 3); % mean
%!    set (h(5:end), 'color', 'k');
%!    axis tight
%!    xlabel ('x')
%!    ylabel ('y')
%!    legend (h, {'noiseless', 'noisy', 'mean', 'median'})
%! #####
%! # Moving window statistics. The plot highlights mean and median. black lines
%! # show minimum, first quartile, third quartile, and maximum.
%! # This illustrates the use of functions with multidimensional output.

This can be achieved in many other ways (some mentioned in the
docstring), but it might come handy to generate simpler and shorter
scripts.

movfun is not yet handling functions with multiple input arguments, I
haven't thought yet if this can be smoothly integrated or needs a
different function or branch inside movfun, so I do not know if movfun
will offer this in the future. To handle this situation I provide the
slicer function movslice. This way the user can implement their own
movfun that works with multiple input arguments. Also they can
implement their own unsafe movfun if they want to avoid some calling
overhead (mainly due to checks), or if they want to parallelize or
execute in batches some parts of the algorithm (for speed or due to
memory constraints).
The function movslice and reshapemod (as repelem, upsamplefill
(signal), and many others in OF packages) can be consider as basic
tools in a vectorizing toolbox.

I know the risk of implementing beyond matlab's functionalities, in
this case I deem it worth it.

Regards,