From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.194.227 with SMTP id hz3mr1976946pac.87.1474143286662; Sat, 17 Sep 2016 13:14:46 -0700 (PDT) X-Received: by 10.157.8.164 with SMTP id 33mr1430822otf.2.1474143286612; Sat, 17 Sep 2016 13:14:46 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!u18no1434068ita.0!news-out.google.com!w143ni4224itb.0!nntp.google.com!u18no1434066ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 17 Sep 2016 13:14:46 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=50.250.26.106; posting-account=3pYsyQoAAACcI-ym7XtMOI2PDU8gRZS5 NNTP-Posting-Host: 50.250.26.106 References: <5db08ea5-c088-4d16-9d88-d058e4bc48df@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <0c8af88c-feeb-4aad-9a05-017dbf406ab5@googlegroups.com> Subject: Re: Ada.Numerics.Float_Random.Generator question From: Andrew Shvets Injection-Date: Sat, 17 Sep 2016 20:14:46 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:31802 Date: 2016-09-17T13:14:46-07:00 List-Id: On Saturday, September 17, 2016 at 4:10:03 PM UTC-4, J-P. Rosen wrote: > Le 17/09/2016 =C3=A0 21:40, Andrew Shvets a =C3=A9crit : > > 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.) >=20 > 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... >=20 > 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. > --=20 > 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 So, basically, there is no equally elegant solution for floats as there is = for Ada.Numerics.Discrete_Random and integer types. That's unfortunate.