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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8147387fe25d4e2a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Random number generation Date: Thu, 30 Dec 2010 15:22:00 +0200 Organization: Tidorum Ltd Message-ID: <8o3fboFsniU1@mid.individual.net> References: <864o9vbkwz.fsf@gareth.avalon.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net bjX7E9KaVxLRAX2xyzetpg70VXHgV4FqteBSE4b9o8uQh4kemt Cancel-Lock: sha1:zbHIs3oA4OSB+zyR3pAdJblGEdU= User-Agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100328) In-Reply-To: Xref: g2news1.google.com comp.lang.ada:16255 Date: 2010-12-30T15:22:00+02:00 List-Id: Dmitry A. Kazakov wrote: > BTW, a sum of n realizations of a uniformly distributed random number is > distributed uniformly with the factor n. So you need not to run a cycle > within Roll: > > function Roll > ( Dice : Generator; > Number : in Positive; > Size : in Positive; > Modifier : in Integer := 0 > ) return Integer is > begin > return Number * ((Random (Dice) mod Size) + 1) + Modifier; > end Roll; I don't think that gives uniformly distributed numbers, since it only produces results that are some multiple of Number, plus the Modifier. The OP's implementation gives a more uniform result. The multiplication formula might work for floating-point values, depending on how fine-scaled uniformity is needed. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .