From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 061F9BC48 for ; Wed, 9 Mar 2005 14:34:38 +0100 (CET) Received: from [128.93.8.130] (macadam.inria.fr [128.93.8.130]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j29DYbbg012837 for ; Wed, 9 Mar 2005 14:34:37 +0100 Mime-Version: 1.0 (Apple Message framework v619.2) In-Reply-To: <20050308215621.GD1877@first.in-berlin.de> References: <293072a520e3724a0497e6456a8675be@mac.com> <200503071330.49084.jon@jdh30.plus.com> <87oedvcypd.fsf-monnier+gmane.comp.lang.caml.inria@gnu.org> <200503071710.52544.jon@jdh30.plus.com> <20050308215621.GD1877@first.in-berlin.de> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <0da7ad8919dcc39da85e0942d847bc97@inria.fr> Content-Transfer-Encoding: 7bit From: Damien Doligez Subject: Re: [Caml-list] Re: exception safety / RAII ? Date: Wed, 9 Mar 2005 14:34:44 +0100 To: caml-list X-Mailer: Apple Mail (2.619.2) X-Miltered: at nez-perce with ID 422EFB6D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; damien:01 damien:01 caml-list:01 oliver:01 bandel:01 reals:01 uniformly:01 rounding:01 ...:98 wrote:01 exception:01 doligez:01 doligez:01 floats:01 behaviour:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: On Mar 8, 2005, at 22:56, Oliver Bandel wrote: > P.S.: I tried Random.float max_float and it seems to be always between > 1. * 10^307 ... 1. * 10^308 > Is this a problem of initialization, or a problem of the > Random-algorithm, > or a kind of strange (?) behaviour of a random walk? I've seen some 10^306 too. If you think about it, 99% of the reals between 0 and 10^308 are in the 10^306..10^308 range. But it's true that there is a "problem": roughly speaking, Random.float simply takes a (uniformly distributed) real between 0 and 1, rounds it to the nearest float, and multiplies by its argument. So in your case it will never return a number greater than 0 and smaller than epsilon * max_float. It's not clear what the spec should be anyway. If you want a uniform distribution on the real interval and rounding to the nearest float, then the missing result range has a vanishingly small probability anyway. If you want a uniform distribution on the (finite) set of floats in the interval, you will get really counter-intuitive results and a function that cannot be used for physical simulations. -- Damien