|
From: | Rik |
Subject: | Re: Test failure in logncdf.m |
Date: | Tue, 12 Jun 2012 10:07:37 -0700 |
On 06/12/2012 06:10 AM, address@hidden wrote:
6/12/12Date: Mon, 11 Jun 2012 23:21:37 +0100 From: Michael Goffioul <address@hidden> To: Octave Maintainers List <address@hidden> Subject: Test failure in logncdf.m Message-ID: <address@hidden> Content-Type: text/plain; charset="iso-8859-1" Hi, After recompiling octave (default branch) today, I noticed additional test failures in logncdf. See one detailed example below, but in all cases the difference between expected and actual result is below eps. I've made several changes to my setup recently (mainly to re-use more math functions from mingw) and this probably generated those new errors. But what I'm not sure is whether the actual result should be *exactly* as the expected one, or should some tolerance be allowed? One such failure is: ***** assert (logncdf (x, zeros (1,5), sqrt(2)*ones (1,5)), y) !!!!! test failed assert (logncdf (x, zeros (1, 5), sqrt (2) * ones (1, 5)),y) expected 0.00000 0.00000 0.50000 0.76025 1.00000 but got 0.00000 0.00000 0.50000 0.76025 1.00000 values do not match shared variables scalar structure containing the fields: x = -1.00000 0.00000 1.00000 2.71828 Inf y = 0.00000 0.00000 0.50000 0.76025 1.00000 On my compiled octave, I can verified that the error is below eps: octave.exe:1> x = [-1 0 1 e Inf]; octave.exe:2> y = [0, 0, 0.5, 1/2+1/2*erf(1/2), 1]; octave.exe:3> logncdf (x, zeros (1,5), sqrt(2)*ones (1,5)) - y ans = 0.0000e+000 0.0000e+000 0.0000e+000 -1.1102e-016 0.0000e+000 Michael, I don't know whether this is particularly worth debugging or simply silencing it by adding an eps to the tolerance for these tests. I wrote the tests for the statistical distributions and, where possible, I used elementary values that would be transformed by the distribution into equally simple values. In this case, logncdf (e) is transformed into erfc (-1/2) / 2. The reference value for the comparison (y) is that same value re-written using the identity erfc(x) = 1 - erf(x) and recognizing that erf is an odd function so that erf(-x) = - erf(x). I don't experience a problem if both erf and erfc are from the C math library. If I comment out HAVE_ERF and HAVE_ERFC in config.h and re-compile then I switch over to the Fortran implementations of these functions in libcruft. At that point I see a small difference which is below 1*eps. It would be interesting to know where you are pulling your erf function from by checking config.h. The second thing I notice is that I used the mathematical identity 1/sqrt(2) * 1/sqrt(2) = 1/2. If I set the reference value (y) to 1/2 + 1/2*erf(1/sqrt(2) * 1/sqrt(2)) then the small difference goes away even with the Fortran erf routines. Does this work for you as well? Even with all that, it might make sense just to add eps to the tolerance of these tests. --Rik |
[Prev in Thread] | Current Thread | [Next in Thread] |