[Pkg-octave-commit] [octave-statistics] 03/04: d/p/small-k-in-gev-functions.patch: New patch

Rafael Laboissière rlaboiss-guest at moszumanska.debian.org
Sat May 2 16:27:17 UTC 2015


This is an automated email from the git hooks/post-receive script.

rlaboiss-guest pushed a commit to branch master
in repository octave-statistics.

commit f2dfe3ed991a228c13026e390211baa1d35ca24b
Author: Rafael Laboissiere <rafael at laboissiere.net>
Date:   Sat May 2 13:07:07 2015 -0300

    d/p/small-k-in-gev-functions.patch: New patch
---
 debian/patches/series                         |  1 +
 debian/patches/small-k-in-gev-functions.patch | 55 +++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/debian/patches/series b/debian/patches/series
index d8263f2..3b241f5 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
 data-files-for-tests.diff
 expose-tbl-delim-tests.patch
 use-corr-instead-of-cor.patch
+small-k-in-gev-functions.patch
diff --git a/debian/patches/small-k-in-gev-functions.patch b/debian/patches/small-k-in-gev-functions.patch
new file mode 100644
index 0000000..5db9ce4
--- /dev/null
+++ b/debian/patches/small-k-in-gev-functions.patch
@@ -0,0 +1,55 @@
+Description: Appropriate results of gev(c|p)df function for small values of k
+ When computing the cdf and pdf of the GEV distributions, in functions
+ gevcdf and gevpdf, respectively, the parameter k appears in the
+ denominator of a division operation. To avoid division by zero, the
+ condition k==0 is tested and an alternative formula is used for it.
+ .
+ However, this test should be extended to values very close to zero.
+ Doing some non-extensive tests, I concluded that the function returns
+ wrong results for values of abs(k) lesser than 1e-11. Nir Krakauer
+ has set the limit as a funciton of eps.
+ .
+ This problem was evidenced in unit tests of the gevcdf and gevpdf
+ functions. In one case, we have:
+ .
+ k = -0.03 : 0.01 : 0.03;
+ .
+ In my system (Octave 4.0 on Debian i386), the fourth element of k is
+ different from zero (it is equal 3.4694e-18) and the result of gevcdf
+ is clearly wrong, and the unit test fails.
+Author: Rafael Laboissiere <rafael at laboissiere.net>
+Origin: upstream, http://sourceforge.net/p/octave/statistics/ci/{eff9575,298bde9}
+Bug: https://savannah.gnu.org/bugs/index.php?44986
+Last-Update: 2015-05-02
+
+--- octave-statistics-1.2.4.orig/inst/gevcdf.m
++++ octave-statistics-1.2.4/inst/gevcdf.m
+@@ -94,7 +94,7 @@ function p = gevcdf (x, k, sigma, mu)
+   p(z <= 0 & x < mu) = 0;
+   p(z <= 0 & x > mu) = 1;  
+   
+-  inds = (k == 0); %use a different formula
++  inds = (abs (k) < (eps^0.7)); %use a different formula if k is very close to zero
+   if any(inds)
+     z = (mu(inds) - x(inds)) ./ sigma(inds);
+     p(inds) = exp(-exp(z));
+--- octave-statistics-1.2.4.orig/inst/gevpdf.m
++++ octave-statistics-1.2.4/inst/gevpdf.m
+@@ -78,7 +78,7 @@ function y = gevpdf (x, k, sigma, mu)
+   endif
+ 
+   if (isempty (x) || isempty (k) || isempty (sigma) || isempty (mu) || ~ismatrix (x) || ~ismatrix (k) || ~ismatrix (sigma) || ~ismatrix (mu))
+-    error ("gevpdf: inputs must be a numeric matrices");
++    error ("gevpdf: inputs must be numeric matrices");
+   endif
+ 
+   [retval, x, k, sigma, mu] = common_size (x, k, sigma, mu);
+@@ -93,7 +93,7 @@ function y = gevpdf (x, k, sigma, mu)
+ 
+   y(z <= 0) = 0;
+   
+-  inds = (k == 0); %use a different formula
++  inds = (abs (k) < (eps^0.7)); %use a different formula if k is very close to zero
+   if any(inds)
+     z = (mu(inds) - x(inds)) ./ sigma(inds);
+     y(inds) = exp(z-exp(z)) ./ sigma(inds);

-- 
Alioth's /home/groups/pkg-octave/bin/git-commit-notice on /srv/git.debian.org/git/pkg-octave/octave-statistics.git



More information about the Pkg-octave-commit mailing list