libtool
[Top][All Lists]
Advanced

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

Re: library interfaces and pseudo-random number generators


From: Vincent Lefevre
Subject: Re: library interfaces and pseudo-random number generators
Date: Mon, 20 Feb 2006 12:33:48 +0100
User-agent: Mutt/1.5.11-vl-20060130

On 2006-02-20 10:10:02 +0100, Ralf Wildenhues wrote:
> Good question.  I'd say that depends on documentation: if the interface
> was documented to either provide a certain PRNG, or weaker, if it was
> documented to provide deterministic series, then that would likely
> change the library interface.  If OTOH it was explicitly documented to
> have an unstable or non-deterministic algorithm, then it would not
> necessarily be a change of interface: the user should not have relied on
> it then.  A more extreme case would be if the library documented to
> optionally make use of a real (non-pseudo) RNG with the same interface.

I agree. The problem is that in the current version, this is not
documented; worse, the PRNG of another library is used (more precisely,
this is MPFR 2.2.0, which uses the PRNG of GMP -- however the user
could guess that since MPFR is based on GMP, and more or less an
extension of GMP). Since it is not documented, I can see 2 cases:

  1. The user thinks that since nothing is specified, anything can
     happen.

  2. The user thinks that results should be reproducible (he can check
     that with MPFR 2.2.0) and assumes that this is a feature that
     must be kept with new MPFR versions (compatible with the current
     interface). Also, if his program uses the PRNG of GMP, he should
     get the same results (i.e. the MPFR version shouldn't affect his
     direct calls to the GMP random functions).

Considering that the interface is different would be safer if there
are users of case 2.

More generally, I assume that a library that uses a PRNG of some
external library (e.g. glibc with rand() or another library if a
global state is used) must document it, since this can affect the
calling program if this program uses the same PRNG.

Regards,

-- 
Vincent Lefèvre <address@hidden> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA




reply via email to

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