bugGNU Octave - Bugs: bug #45518, randsample not implemented ...

 
 

bug #45518: randsample not implemented (implementation supplied)

Submitter:  Lachlan Andrew <lachlan>
Submitted:  Fri 10 Jul 2015 07:26:56 AM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Feature Request
Status:  Fixed Assigned to:  None
Originator Name:  Lachlan Open/Closed:  * Closed
Release:  * 4.0.0 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 10 Jul 2018 09:51:26 AM UTC, comment #7: 

This has been reported as a new bug #54278

Richard Lane <richardlane>
Thu 28 Jun 2018 08:11:48 PM UTC, comment #6: 

Richard - please file a new bug report. Your comment doesn't seem to have anything to do with this bug report that has been fixed years ago.

Mike Miller <mtmiller>
Group Member
Thu 28 Jun 2018 03:13:22 PM UTC, comment #5: 

There is a bug on line 233 of  gmdistribution in statistics-1.4.0, octave-4.4.0.

This causes gmdistribution.random to fail if obj.NumVariables ~= obj.NumComponents.

Reproduce the error:
x = rand(100,2);
gmm = fitgmdist(x,5);
gmm.random(1)

Solution:
line 233: obj.NumVariables should be obj.NumComponents

Richard Lane <richardlane>
Sat 11 Jul 2015 03:32:43 PM UTC, comment #4: 

Thanks, I applied your patch to the repository function.

Nir Krakauer <nir_krakauer>
Sat 11 Jul 2015 02:36:01 AM UTC, comment #3: 

Thanks, Nir.  I didn't notice your implementation -- I checked for it in 3.8.2 instead of 4.0.0 / development.

The attached patch:
- fixes a bug that prevents sampling k from n<k with replacement
- implements weighted sampling without replacement, which is also missing from Matlab, but should really be there
- puts brackets around if/while conditions, which I was told is an Octave coding standard.

(file #34423)

Lachlan Andrew <lachlan>
Fri 10 Jul 2015 04:07:40 PM UTC, comment #2: 

Adding package maintainer to CC list.

Could you also add some test blocks to the function?

Carnë Draug <carandraug>
Group Member
Fri 10 Jul 2015 12:40:53 PM UTC, comment #1: 

randsample is already available in the Octave Forge Statistics package: https://sourceforge.net/p/octave/statistics/ci/6672813641f9ce95884a20f29fa2c420f680d253/tree/inst/randsample.m

So it would be better to either use the existing function, or supply a patch for it if for some reason it doesn't meet your needs.

Nir Krakauer <nir_krakauer>
Fri 10 Jul 2015 07:26:56 AM UTC, original submission:  

The attached file implements Matlab's  randsample, which is used by the  gmdistribution and fitgmdist  files provided in bug reports #45516 and #45517.

Lachlan Andrew <lachlan>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #34423:  randsample.patch added by lachlan (4KiB - text/x-patch - randsample patch allowing k>n for sampling with replacement)
file #34410:  randsample.m added by lachlan (3KiB - text/x-objcsrc - randsample implementation)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by richardlane (Posted a comment)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by carandraug (Arno Onken - maintainer of statistics package)
  • -email is unavailable- added by nir_krakauer (Posted a comment)
  • -email is unavailable- added by lachlan (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-07-11 mtmiller StatusNone Fixed
        Open/ClosedOpen Closed
    2015-07-11 lachlan Attached File- Added randsample.patch, #34423
    2015-07-10 carandraug Carbon-Copy- Added -email is unavailable-
    2015-07-10 lachlan Attached File- Added randsample.m, #34410

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code