octave-maintainers
[Top][All Lists]
Advanced

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

Re: tolerance in binopdf.m


From: Tatsuro MATSUOKA
Subject: Re: tolerance in binopdf.m
Date: Wed, 21 Sep 2011 13:16:28 +0900 (JST)

Hello

On my mingw build, gammaln is implemented as the libcruft/slatec-fn routine.

 
--- On Wed, 2011/9/21, Ben Abbott  wrote:
> > For reference, the fist problematic test ...
> > 
> > x = [-1 0 1 2 3];
> > y = [0 1/4 1/2 1/4 0];
> > z = binopdf (x, 2 * ones (1, 5), 0.5 * ones (1, 5));
> > z - y
> > ans =   0.0000e+00   0.0000e+00   1.1102e-16   0.0000e+00   0.0000e+00

octave:3>  x = [-1 0 1 2 3];
octave:4> y = [0 1/4 1/2 1/4 0];
octave:5> z = binopdf (x, 2 * ones (1, 5), 0.5 * ones (1, 5));
octave:6>  z - y
ans =

   NaN     0     0     0   NaN

>exp (gammaln (3)) * exp (2 * log (0.5)) - 0.5
>ans = 0
>exp (gammaln (3) + 2 * log (0.5)) - 0.5
>ans =  1.1102e-16

octave:8> exp (gammaln (3)) * exp (2 * log (0.5)) - 0.5
ans = 0
octave:10> exp (gammaln (3) + 2 * log (0.5)) - 0.5
ans = 0

> Looking at these individually ...
> 
> printf ("%.17f\n", log (0.5))
> -0.69314718055994529
>  printf ("%.17f\n", gammaln (3))
> 0.69314718055994540

octave:11> printf ("%.17f\n", log (0.5))
-0.69314718055994529
octave:12> printf ("%.17f\n", gammaln (3))
0.69314718055994529

Regards

Tatsuro


reply via email to

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