comp.lang.ada
 help / color / mirror / Atom feed
From: "J-P. Rosen" <rosen@adalog.fr>
Subject: Re: Ada.Numerics.Float_Random.Generator question
Date: Sat, 17 Sep 2016 22:09:59 +0200
Date: 2016-09-17T22:09:59+02:00	[thread overview]
Message-ID: <nrk7uk$q8$1@dont-email.me> (raw)
In-Reply-To: <5db08ea5-c088-4d16-9d88-d058e4bc48df@googlegroups.com>

Le 17/09/2016 à 21:40, Andrew Shvets a écrit :
> This works.  However, as I'm now looking into the
> Ada.Numerics.Discrete_Random package, I've noticed that it can
> generate a random value based on the type that is passed in.  This
> appeals to me and I'd like to do the same for a custom float type
> (say I want the delta to be 0.01.)

Beware! Random number generators are tricky. It took megabytes of
discussion to come to the conclusion that it was not possible to make a
proper discrete generator out of a floating point generator...

Now, if you want a delta of 0.01, it looks more like a fixed point than
a floating point. This can be easily achieved by instantiating
discrete_random on an integer type with the proper number of values and
then multiplying by 0.01.
-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr


  reply	other threads:[~2016-09-17 20:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-17 19:40 Ada.Numerics.Float_Random.Generator question Andrew Shvets
2016-09-17 20:09 ` J-P. Rosen [this message]
2016-09-17 20:14   ` Andrew Shvets
2016-09-17 21:01 ` Jeffrey R. Carter
2016-09-17 23:53   ` Andrew Shvets
2016-09-19 19:07 ` rieachus
2016-09-25 23:41 ` brbarkstrom
2016-09-26 13:04   ` Robert Eachus
2016-09-26 18:48     ` brbarkstrom
2016-09-29  9:42       ` Some Dude
2016-10-01  3:35         ` Robert Eachus
2016-10-01  3:59           ` Paul Rubin
2016-10-01 14:23             ` Robert Eachus
2016-10-01 15:49               ` Dmitry A. Kazakov
2016-10-01 16:44                 ` Robert Eachus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox