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

 
 

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

Submitter:  Markus Ebner <seijikun>
Submitted:  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
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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, ...);
endif


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


Rik <rik5>
Group 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.
https://uk.mathworks.com/help/matlab/ref/movstd.html?s_tid=doc_srchtitle#bu5le86-1-w

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:
   
   
Comment:
   

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)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group 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.13-02a9.
    Corresponding source code