bugGNU Octave - Bugs: bug #39938, make qqplot ML compatible

 
 

bug #39938: make qqplot ML compatible

Submitter:  Muhali <muhali>
Submitted:  Wed 04 Sep 2013 08:45:03 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
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
   

Mon 21 Oct 2013 08:04:29 PM UTC, comment #5: 

I applied your patch with a few modifications here (http://hg.savannah.gnu.org/hgweb/octave/rev/e243a3a19831).  This will be part of the 3.8 release due in a few weeks.  Thanks for contributing.

Rik <rik5>
Group administrator
Mon 09 Sep 2013 06:56:32 AM UTC, comment #4: 

input checking for dist was still incorrect and is now replaced by

 if ( isnumeric(dist) )...

the new and hopefully final patch is attached.


(file #29091)

Muhali <muhali>
Sat 07 Sep 2013 03:25:13 PM UTC, comment #3: 

To be fully compatible to tex the q_label needs to be fixed, so the patch reads


--- /a/qqplot.m
+++ /b/qqplot.m
@@ -18,8 +18,9 @@

 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {[@var{q}, @var{s}] =} qqplot (@var{x})
+## @deftypefnx {Function File} {[@var{q}, @var{s}] =} qqplot (@var{x}, @var{y})
 ## @deftypefnx {Function File} {[@var{q}, @var{s}] =} qqplot (@var{x}, @var{dist})
-## @deftypefnx {Function File} {[@var{q}, @var{s}] =} qqplot (@var{x}, @var{dist}, @var{params})
+## @deftypefnx {Function File} {[@var{q}, @var{s}] =} qqplot (@var{x}, @var{y}, @var{params})
 ## @deftypefnx {Function File} {} qqplot (@dots{})
 ## Perform a QQ-plot (quantile plot).
 ##
@@ -29,6 +30,9 @@
 ## largest element of x versus abscissa @var{q}(@var{i}f) = G((@var{i} -
 ## 0.5)/@var{n}).
 ##
+## If the second argument is a vector @var{y} the empirical CDF of @var{y}
+## is used as @var{dist}.
+##
 ## If the sample comes from F, except for a transformation of location
 ## and scale, the pairs will approximately follow a straight line.
 ##
@@ -65,7 +69,13 @@
   if (nargin == 1)
     f = @stdnormal_inv;
   else
-    if (   exist (invname = sprintf ("%sinv", dist))
+    if ( isvector(dist) )
+       if ( exist("empirical_inv") == 2 )
+          f = @(y) empirical_inv(y, dist) ;
+       else
+          f = @(y) empiricalinv(y, dist) ;
+       endif
+    elseif(   exist (invname = sprintf ("%sinv", dist))
         || exist (invname = sprintf ("%s_inv", dist)))
       f = str2func (invname);
     else
@@ -92,6 +102,7 @@

   if (nargout == 0)
     plot (q, s);
+    q_label = strrep(q_label, "_", "\\_") ;
     xlabel (q_label);
     ylabel ("sample points");
   endif


Muhali <muhali>
Fri 06 Sep 2013 02:28:01 PM UTC, comment #2: 

This patch is for a function in Octave core. qqplot is not part of the statistics package.

Arno Onken <asnelt>
Wed 04 Sep 2013 04:58:55 PM UTC, comment #1: 

Added maintainer of the package to CC list.

Carnë Draug <carandraug>
Group Member
Wed 04 Sep 2013 08:45:03 AM UTC, original submission:  

The attached patch makes qqplot accept a data array as a second argument, as in ML. Its empirical quantiles are used for the plot.


--- /a/qqplot.m
+++ /b/qqplot.m
@@ -18,8 +18,9 @@

 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {[@var{q}, @var{s}] =} qqplot (@var{x})
+## @deftypefnx {Function File} {[@var{q}, @var{s}] =} qqplot (@var{x}, @var{y})
 ## @deftypefnx {Function File} {[@var{q}, @var{s}] =} qqplot (@var{x}, @var{dist})
-## @deftypefnx {Function File} {[@var{q}, @var{s}] =} qqplot (@var{x}, @var{dist}, @var{params})
+## @deftypefnx {Function File} {[@var{q}, @var{s}] =} qqplot (@var{x}, @var{y}, @var{params})
 ## @deftypefnx {Function File} {} qqplot (@dots{})
 ## Perform a QQ-plot (quantile plot).
 ##
@@ -29,6 +30,9 @@
 ## largest element of x versus abscissa @var{q}(@var{i}f) = G((@var{i} -
 ## 0.5)/@var{n}).
 ##
+## If the second argument is a vector @var{y} the empirical CDF of @var{y}
+## is used as @var{dist}.
+##
 ## If the sample comes from F, except for a transformation of location
 ## and scale, the pairs will approximately follow a straight line.
 ##
@@ -65,7 +69,13 @@
   if (nargin == 1)
     f = @stdnormal_inv;
   else
-    if (   exist (invname = sprintf ("%sinv", dist))
+    if ( isvector(dist) )
+       if ( exist("empirical_inv") == 2 )
+          f = @(y) empirical_inv(y, dist) ;
+       else
+          f = @(y) empiricalinv(y, dist) ;
+       endif
+    elseif(   exist (invname = sprintf ("%sinv", dist))
         || exist (invname = sprintf ("%s_inv", dist)))
       f = str2func (invname);
     else
@@ -92,6 +102,7 @@

   if (nargout == 0)
     plot (q, s);
+    q_label = strrep(q_label, "_", "\_") ;
     xlabel (q_label);
     ylabel ("sample points");
   endif


Muhali <muhali>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #29091:  patch added by muhali (2KiB - application/octet-stream)

 

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 mtmiller (Updated the item)
  • -email is unavailable- added by asnelt (Posted a comment)
  • -email is unavailable- added by carandraug (Arno Onken - maintainer of the statistics package)
  • -email is unavailable- added by muhali (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-10-21 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2013-09-09 muhali Attached File- Added patch, #29091
    2013-09-07 mtmiller CategoryOctave Package Octave Function
        StatusNone Patch Submitted
        Summarypkg statistics: make qqplot ML compatible make qqplot ML compatible
    2013-09-04 carandraug Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code