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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6e2278eaed9619d6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-13 09:15:02 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!195.54.122.107!newsfeed1.bredband.com!bredband!diablo.netcom.net.uk!netcom.net.uk!itchen!hamble.qinetiq.com!not-for-mail From: "Kevin Rigotti" Newsgroups: comp.lang.ada Subject: Re: Discrete random with given distribution ? Date: Thu, 13 Jun 2002 17:10:42 +0100 Organization: Airspace management department, QinetiQ Message-ID: References: <3D08AB63.6AF60F95@despammed.com> NNTP-Posting-Host: 10.184.84.210 X-Trace: hamble.qinetiq.com 1023984654 32676 10.184.84.210 (13 Jun 2002 16:10:54 GMT) X-Complaints-To: postmaster@qinetiq.com NNTP-Posting-Date: Thu, 13 Jun 2002 16:10:54 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Xref: archiver1.google.com comp.lang.ada:25882 Date: 2002-06-13T17:10:42+01:00 List-Id: Wes Groleau wrote in message news:3D08AB63.6AF60F95@despammed.com... > > F := FR.Random; > Loop_With_Jump_Out: > for I in Out_Type loop > if F > Threshold (I) then > return I; > end if; > end loop Loop_With_Jump_Out; If any of the enumeration values has probability zero then you want to start looking at the other end of the table and work backwards, until you find a cumulative probability value that is greater than its predecessor, ie. for I in reverse Out_Type range 2 .. Out_Type'Last .... Kevin -- ATC Systems Group, QinetiQ, St Andrews Road, Malvern, Worcestershire WR14 3PS, UK Phone +44 (0)1684 89 69 11, fax +44(0)1684 89 41 09 QinetiQ disclaimers and restrictions apply, details on request