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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,219de4148f968c92 X-Google-Attributes: gid103376,public From: Andreas Almroth Subject: Re: Strange results with random numbers with Gnat 3.10 Date: 1998/01/08 Message-ID: <34B46DA3.F65@uppsala.mail.telia.com>#1/1 X-Deja-AN: 313867345 Content-Transfer-Encoding: 7bit References: <34B3F618.DC9@uppsala.mail.telia.com> <34B3FDCB.A861170@elca-matrix.ch> Mime-Version: 1.0 Reply-To: andreas.almroth@uppsala.mail.telia.com X-NNTP-Posting-Host: t2o61p46.telia.com Content-Type: text/plain; charset=us-ascii Organization: A3CE, Advanced Computer Engineering Newsgroups: comp.lang.ada Date: 1998-01-08T00:00:00+00:00 List-Id: Mats Weber wrote: > > > I compiled and ran the dice example program, and everything > > seemed OK. But just as a curiousity I wanted to see how the > > numbers were actually distributed, so I changed the program > > to loop one million times, and then present the frequency. > > Please show us the code. It's very easy to make a rounding mistake, which is > what seems to be the case here. Ok, below is the program. I've double checked the code, but maybe I'm not up to it, I can't find were the problem possibly could be in this code. -- dice game with Text_Io; use Text_Io; with Ada.Numerics.Discrete_Random; procedure Dice_Game is subtype Die is Integer range 1 .. 6; subtype Dice is Integer range 2*Die'First .. 2*Die'Last; type Pins is array(1..6) of Integer range 0..1000000; package Random_Die is new Ada.Numerics.Discrete_Random (Die); package Dice_Io is new Integer_Io(Integer); use Random_Die; use Dice_Io; G : Generator; D : Die; P : Pins; begin for I in 1..6 loop P(I) := 0; end loop; Reset (G); for I in 1..1000000 loop D := Random(G); P(D) := P(D) + 1; end loop; for I in 1..6 loop Put(P(I)); New_Line; end loop; end Dice_Game; Regards, Andreas Almroth