bugGNU Octave - Bugs: bug #33935, demo function humps is not defined

 
 

bug #33935: demo function humps is not defined

Submitter:  None
Submitted:  Wed 03 Aug 2011 06:26:56 AM UTC
   
 
Category:  Octave Function Severity:  1 - Wish
Priority:  1 - Later Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Alex Feng Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 11 Aug 2017 04:48:31 PM UTC, comment #10: 

I refreshed the patch for the current development sources, made a few additional minor fixes, and pushed the changeset here:

http://hg.savannah.gnu.org/hgweb/octave/rev/86a49caa5100

Thanks!

John W. Eaton <jwe>
Group administrator
Wed 08 Feb 2017 02:09:31 PM UTC, comment #9: 

updated patch. included @tex  and @ifnotex versions of equation in doc section.

(file #39703)

Nicholas Jankowski <nrjank>
Group Member
Sun 05 Feb 2017 03:43:16 AM UTC, comment #8: 

added a couple extra tests and a demo.  no argument is just supposed to return the function value for compatibility, so didn't make it plot. but the demo pops up a plot and is mentioned in the help.

Looking at matlab, humps is only mentioned when used as an example for fzero and fminsearch, etc. 

So I dropped it into the optimization folder, and added it to the manual after those functions with a mention that it is a useful test function.

changeset added including mfile, module.mk, doc change and added function name to news. Also attached the updated m file.

(file #39665, file #39666)

Nicholas Jankowski <nrjank>
Group Member
Tue 31 Jan 2017 12:06:23 PM UTC, comment #7: 

In Octave, we don't error on nargout being too large, we just let it go and then you get a generic warning about undefined outputs.

If you call error before print_usage, the print_usage function will never be executed.

Instead of checking nargin, you could use a default input value.

The whole function could then be


function varargout = humps (x = [0:0.05:1])
  if (nargin > 1)
    print_usage ();
  endif

  y = ...;

  if (nargout > 1)
    varargout = {x, y};
  else
    varargout = {y};
  endif
endfunction


Also, @var{x} will capitalize its argument when generating Info output, but will not when generating TeX output (it uses a slanted font instead), so you should write @var{x}, not @var{X}.

Could someone make those changes and also create a proper changeset that adds this file to some directory (which one?  Octave doesn't currently have a demos directory), updates the corresponding module.mk file, and adds the function to the manual?

I suppose it could be included along with sombrero and peaks.  Maybe make it plot the function if nargout is 0?

And, for completeness, maybe add a test or two just so it doesn't add to the count of functions without tests?

Thanks.

John W. Eaton <jwe>
Group administrator
Fri 27 Jan 2017 10:32:11 AM UTC, comment #6: 

patch reviewed.

Maintainers: please review and push this patch.

Avinoam Kalma <avinoam>
Group Member
Sat 19 Nov 2016 03:22:58 PM UTC, comment #5: 

The Matlab demo functioin "humps.m" is still missing in Octave 4.2.0.

An Octave version of this m-file is attached to comment #4.

Hartmut <hardy>
Sun 13 Dec 2015 09:52:06 PM UTC, comment #4: 

tweaked the help text to remove the function class type from the docstring as per recent Octave Code Sprint activity.

(file #35735)

Nicholas Jankowski <nrjank>
Group Member
Sun 13 Dec 2015 02:49:43 AM UTC, comment #3: 

attached with added help and tests. Think this version is complete. only thing it's missing are any 'see also's. it doesn't seem to relate to anything. matlab help only had it 'see also' some demo functions that used it. can generate a patch if someone tells me where it should go. not sure what part of the docs it would fit into. there is a section on demo plots like sombrero and peaks, but this function doesn't plot anything.

(file #35725)

Nicholas Jankowski <nrjank>
Group Member
Sat 12 Dec 2015 10:09:19 PM UTC, comment #2: 

saw this looking through old 'need infos'. (website sorts by type with oldest first)

peeking at humps, it looks like a rational function which I've been playing with recently. Used rational polynomial fit tool along with humps([-10:.01:10]). Got a R2=1 fit with m=n=4. normalized coefficients with Maxima and got the following:


f(x) = - (1200*x^4-2880*x^3+2036*x^2-348*x - 88) / (200*x^4-480*x^3+406*x^2-138*x + 17)

Goodness of fit:
  SSE: 2.201e-24
  R-square: 1
  Adjusted R-square: 1
  RMSE: 3.324e-14


plot seems to overlap perfectly, too.

I remember 'way' back when using humps as a good test function with close local maxima for peak finding, thought it may be useful to have. Since it popped out so easily, thought I'd code it up.

1st cut m-file attached. not quite ready for a patch/submission yet. i think I got all the use cases right.  need help/usage and tests.

chalk it up to me procrastinating on other work by taking care of those 'high priority' needs. ;)

(file #35722)

Nicholas Jankowski <nrjank>
Group Member
Mon 08 Aug 2011 04:26:58 PM UTC, comment #1: 

It looks to me like the humps function is a demo function in Matlab, not a part of the core functions.  Do you really expect that Octave provides all the Matlab demo functions?  To me, this has a really low priority.  But if someone provides an independent implementation, then I guess it could be included in Octave.

John W. Eaton <jwe>
Group administrator
Wed 03 Aug 2011 06:26:56 AM UTC, original submission:  

The function humps is a function provided by MatLab, but it is not defined for Octave. Here is the info provided by Matlab:  http://www.mathworks.com/products/matlab/demos.html?file=/products/demos/shipping/matlab/funfuns.html

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #39703:  add_humps_v2.diff added by nrjank (5KiB - application/octet-stream - updated patch, adds tex version of formula to documentation)
file #39666:  humps.m added by nrjank (3KiB - application/octet-stream - 'final' versions)
file #39665:  add_humps.diff added by nrjank (5KiB - application/octet-stream - 'final' versions)
file #35735:  humps.m added by nrjank (3KiB - application/octet-stream - updated as per comment 4)
file #35725:  humps.m added by nrjank (3KiB - text/x-objcsrc - 'complete' implementation)
file #35722:  humps.m added by nrjank (560B - text/x-objcsrc - 1st implementation of humps.m)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by avinoam (Updated the item)
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by nrjank (Updated the item)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by jwe (Posted a comment)
  •  

    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 18 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-08-11 jwe StatusPatch Reviewed Fixed
        Open/ClosedOpen Closed
    2017-02-08 nrjank Attached File- Added add_humps_v2.diff, #39703
    2017-02-05 nrjank Attached File- Added add_humps.diff, #39665
        Attached File- Added humps.m, #39666
    2017-01-27 avinoam StatusPatch Submitted Patch Reviewed
    2016-11-19 avinoam StatusNeed Info Patch Submitted
    2015-12-13 nrjank Attached File- Added humps.m, #35735
    2015-12-13 nrjank Attached File- Added humps.m, #35725
    2015-12-12 nrjank Attached File- Added humps.m, #35722
    2013-09-29 mtmiller CategoryLibraries Octave Function
        Severity3 - Normal 1 - Wish
        StatusNone Need Info
        Release3.2.4 dev
        Operating SystemMicrosoft Windows Any
        Summarythe function humps is not defined demo function humps is not defined
    2011-08-08 jwe Priority5 - Normal 1 - Later
        Item GroupNone Matlab Compatibility

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code