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

 
 

bug #59804: [octave forge] (statistics) 1.4.2 - fitgmdist - dimension mismatch check inappropriately fails for non-shared Sigma

Submitted by:  Tasos Papastylianou <tpapastylianou>
Submitted on:  Sat 02 Jan 2021 05:15:07 PM UTC  
 
Category:  Octave Forge Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  None Assigned to:  None
Originator Name:  Tasos Papastylianou Open/Closed:  Open
Release:  other Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

Sat 02 Jan 2021 05:15:07 PM UTC, original submission:  

Please see https://stackoverflow.com/a/65530418/4183191 for context and more details.
Note, my 'fix' in that SO article is only a hacky workaround, not really a proper mismatch check in that sense; I assume the maintainer will want to conduct a more comprehensive validation...

In summary, line 197 performs the following check:

if (any (size (data, 2) ~= [size(mu,2), size(Sigma)]) || any (k ~= [size(mu,1), size(p,2)]))
  error ('fitgmdist: Start parameter has mismatched dimensions');
endif

This line is a bit convoluted, but effectively it says the following:
Fail the mismatch check if ANY of the following is true:
1. There is a mismatch between number of features (columns) 'n' in the data, and features (columns) in the mean.
2. There is a mismatch between number of features (columns) 'n' in the data, and ANY of the dimensions of Sigma
3. There is a mismatch between number of components 'k', and number of components (rows) in the mean
4. There is a mismatch between number of components 'k', and number of components (columns) in the component weights (i.e. ComponentProportion)

The error in logic lies in step 2. This would only pass the check in the case of a shared covariance, in which case you would expect Sigma to be a 2D array, of size n×n, and therefore the check any( n ~= [n,n] ) will be false (i.e. no evidence of mismatch). However, in the typical case where Sigma is expected to be n×n×k (one 2D covariance matrix per component considered, stacked along the 3rd dimension), this check will be flagged as true (i.e. evidence of mismatch, since n ~= k), and therefore the code will exit with a dimension mismatch error, instead of accepting an otherwise valid n×n×k Sigma.

Tasos Papastylianou <tpapastylianou>

 

(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 mmuetzel (Updated the item)
  • -email is unavailable- added by tpapastylianou (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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-01-02 mmuetzel Release6.1.0 => other
        Summarystatistics-1.4.2 - fitgmdist - dimension mismatch check inappropriately fails for non-shared Sigma => [octave forge] (statistics) 1.4.2 - fitgmdist - dimension mismatch check inappropriately fails for non-shared Sigma

    Back to the top


    Powered by Savane 3.6