bugGNU Octave - Bugs: bug #56765, movstd, movvar should accept...


bug #56765: movstd, movvar should accept normalization argument for Matlab compatibility

Submitted by:  Markus Ebner <seijikun>
Submitted on:  Fri 16 Aug 2019 09:55:34 PM UTC  
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Feature Request
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  dev Operating System:  GNU/Linux

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Tue 03 Sep 2019 10:08:29 PM UTC, comment #2: 

I added support for a normalization argument in this changeset: https://hg.savannah.gnu.org/hgweb/octave/rev/71d9bd3332e4.  This will be a part of the next Octave release (version 6.1).

Marking as fixed and closing report.

Rik <rik5>
Project Administrator
Sat 17 Aug 2019 07:22:33 PM UTC, comment #1: 

he MathWorks often changes the interfaces of their functions.  When Octave implemented these functions I don't believe movstd and movvar had an additional argument to indicate the normalization to use.

Since both functions are implemented as m-files, this wouldn't be too hard to modify.  Probably just extend the input validation to detect whether the normalization argument is present and then create an anonymous function which embeds the normalization before calling movfun.  In pseudo-code,

# Validate input and detect normalization
normalization = 1;

# Compute moving variance with 1/N normalization
if (normalization != 0)
  varfcn = @(x) var (x, 1);
  y = movfun (@varfcn, ...);

Might have to extend the anonymous varfcn to include a second argument for dimension, but maybe not.  Subject to test.

Rik <rik5>
Project Administrator
Fri 16 Aug 2019 09:55:34 PM UTC, original submission:  

movstd's function-argument surface is incompatible with that of matlab.
Matlab does have an argument called weight, while octave does not.

This leads to incompatibilities like the following:

result = movstd(inputData, windowWidth, 0, 2);

This works in Matlab. The 0 specifies the mentioned weight argument: "Normalize by k-1, where k is the window length. If k=1, the weight is k." (from Matlab documentation)
The 2 specifies the dimension along which to do the calculation.

When the same code is run with octave, it tries to interpret the 0 as dimension parameter, because octave does not seem to support the weight argument.

Markus Ebner <seijikun>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by seijikun (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-09-03 rik5 StatusConfirmed => Fixed
        Open/ClosedOpen => Closed
    2019-08-17 rik5 Item GroupMatlab Compatibility => Feature Request
        StatusNone => Confirmed
        Release5.1.0 => dev
        Summarymovstd argument-surface incompatible with matlab => movstd, movvar should accept normalization argument for Matlab compatibility

    Back to the top

    Powered by Savane 3.5