octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #54009] [octave forge] (statistics) incorrect


From: Muhali
Subject: [Octave-bug-tracker] [bug #54009] [octave forge] (statistics) incorrect result for gppdf
Date: Wed, 27 Jun 2018 04:37:59 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0

Follow-up Comment #1, bug #54009 (project octave):

here is more evidence, if needed:

octave> Q = integral(@normpdf, -Inf, Inf)
Q =  1.000
octave> Q = integral(@(x) gampdf(x, 1, 1), -Inf, Inf)
Q =  1.00
octave> Q = integral(@(x) gevpdf(x, 1, 2, 0), -Inf, Inf)
Q =  1.000
octave> Q = integral(@(x) gppdf(x, 0, 2, 1), -Inf, Inf)
Q =  2.00
octave> Q = integral(@(x) gppdf(x, 0, 3, 1), -Inf, Inf)
Q =  3.00
octave> Q = integral(@(x) gppdf(x, 0, 3, 2), -Inf, Inf)
Q =  3.00


Please note also that the order of arguments (LOCATION, SCALE, SHAPE) is
reversed relative to Matlab.

I attach a patch that fixes the scale issue.


--- /usr/local/src/octave-statistics/inst/gppdf.m
+++ /tmp/gppdf.m
@@ -69,13 +69,13 @@
 
     j = k & (shape > 0) & (z >= 0);
     if (any (j))
-      pdf(j) = (shape * z(j) + 1).^(-(shape + 1) / shape);
+      pdf(j) = (shape * z(j) + 1).^(-(shape + 1) / shape) ./ scale;
     endif
 
     if (shape < 0)
       j = k & (shape < 0) & (0 <= z) & (z <= -1. / shape);
       if (any (j))
-        pdf(j) = (shape * z(j) + 1).^(-(shape + 1) / shape);
+        pdf(j) = (shape * z(j) + 1).^(-(shape + 1) / shape) ./ scale;
       endif
     endif
   else
@@ -88,13 +88,13 @@
 
     j = k & (shape > 0) & (z >= 0);
     if (any (j))
-      pdf(j) = (shape(j) .* z(j) + 1).^(-(shape(j) + 1) ./ shape(j));
+      pdf(j) = (shape(j) .* z(j) + 1).^(-(shape(j) + 1) ./ shape(j)) ./
scale;
     endif
 
     if (any (shape < 0))
       j = k & (shape < 0) & (0 <= z) & (z <= -1 ./ shape);
       if (any (j))
-        pdf(j) = (shape(j) .* z(j) + 1).^(-(shape(j) + 1) ./ shape(j));
+        pdf(j) = (shape(j) .* z(j) + 1).^(-(shape(j) + 1) ./ shape(j)) ./
scale;
       endif
     endif
   endif



    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?54009>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]