bugGNU Octave - Bugs: bug #50286, [octave forge] (statistics)...


bug #50286: [octave forge] (statistics) fitgmdist: No input check and demo doesn't work

Submitter:  None
Submitted:  Sun 12 Feb 2017 10:06:10 AM UTC
Category:  Octave Forge Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Fixed Assigned to:  None
Originator Name:  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 12 Aug 2022 02:42:47 PM UTC, comment #8: 

There was no variable `centers` whatsoever, so I considered that it must have been added accidentally or something.

Andreas Bertsatos <pr0m1th3as>
Fri 12 Aug 2022 02:28:38 PM UTC, comment #7: 

oh, i see the changes now in the other report. just clipped that part out.  looks good. closing report.

Nicholas Jankowski <nrjank>
Group Member
Fri 12 Aug 2022 02:26:08 PM UTC, comment #6: 

what was going on with the

plot (centers (:, 1), centers (:, 2), "kv", "markersize", 10);


Nicholas Jankowski <nrjank>
Group Member
Fri 12 Aug 2022 01:44:17 PM UTC, comment #5: 

The error in demo was fixed by changing

contour (reshape (GMModel.pdf (bbins), heights));


contour (reshape (GMModel.pdf (bbins), size (heights)));

An additional demo has been add. See related bug #59804.
I think we can close this.

Andreas Bertsatos <pr0m1th3as>
Sat 06 Aug 2022 04:11:20 PM UTC, comment #4: 

created a separate bug report about the reshape error handling at bug #62870

also the title indicates missing input checks. John added a nargin check, would be helpful to know what other type checks on data, k, and varargin would be useful.  then some BISTs based on those would probably be helpful.

Nicholas Jankowski <nrjank>
Group Member
Sat 06 Aug 2022 03:59:42 PM UTC, comment #3: 

for easier copy paste here's the current failing demo code that should run after loading the statistics pkg :

## Generate a two-cluster problem
C1 = randn (100, 2) + 1;
C2 = randn (100, 2) - 1;
data = [C1; C2];

## Perform clustering
GMModel = fitgmdist (data, 2);

## Plot the result
[heights, bins] = hist3([C1; C2]);
[xx, yy] = meshgrid(bins{1}, bins{2});
bbins = [xx(:), yy(:)];
contour (reshape (GMModel.pdf (bbins), heights));
hold on
plot (centers (:, 1), centers (:, 2), "kv", "markersize", 10);
hold off

Nicholas Jankowski <nrjank>
Group Member
Sat 06 Aug 2022 03:54:36 PM UTC, comment #2: 

just updating this report with the detail about the failing demo

after successfully running fitgmdist, attempting a contour plot first requires a data reshape, resulting in:

> reshape (GMModel.pdf (bbins), heights)
error: out of memory or dimension too large for Octave's index type

the output from GMModel.pdf(bbins) is 100x1. heights is a 10x10 array (integer valued doubles) coming from a histogram output. the sum of all the elements in heights is 200, and every row/column has at least one zero it it, so I'm really not certain why we're getting the memory/index type error when reshape should really just be erroring about problematic input for the size vector.

ASSUMING the intent was to reshape it into size(heights), which does work, you then get a contour plot with two peaks.  unfortunately, the next line:

plot (centers (:, 1), centers (:, 2), "kv", "markersize", 10)

is asking for a variable centers that has never been defined, nad there is no such prop/method for GMModel.  based on the contour plot, I assume there's some way to pull out markers for the two peak values to plot, and that was the intent, but not being familiar with the gmdistribution class, I didn't see any with a quick scan. 

perhaps if someone who knows the original intent or is familiar with that class can supply that info, that line can be corrected and the demo will run.

i see @lachlan as the original copyright. adding to cc in case he's still around and has insight.

it might also be worth checking why the reshape command is producing the memory/limit error instead of failing an input size check in the current code.

Nicholas Jankowski <nrjank>
Group Member
Wed 09 May 2018 12:12:48 PM UTC, comment #1: 

Pushed change to check for input args.


The demo is currently still failing

John Donoghue <lostbard>
Group Member
Sun 12 Feb 2017 10:06:10 AM UTC, original submission:  

Dear all, using octave-statistics from hg repo


the demo for fitgmdist doesn't work and while looking at the code I see that there is even no input checks

octave:1> fitgmdist
error: 'data' undefined near line 103 column 28
error: called from
    fitgmdist at line 103 column 8



(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 pr0m1th3as (Posted a comment)
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by nrjank
  • -email is unavailable- added by nrjank
  • -email is unavailable- added by lostbard (Posted a comment)
  • -email is unavailable- added by jwe (Updated 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 project members can vote.


    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-08-12 nrjank StatusNeed Info Fixed
        Open/ClosedOpen Closed
    2022-08-06 nrjank Item GroupNone Unexpected Error or Warning
        StatusNone Need Info
        Release4.2.0 dev
        Carbon-Copy- Added lachlan
        Carbon-Copy- Added pr0m1th3as
    2017-08-12 jwe Summaryoctave-statistics: fitgmdist: No input check and demo doesn't work [octave forge] (statistics) fitgmdist: No input check and demo doesn't work

    Back to the top

    Powered by Savane 3.12