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-18 17:35:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newspeer.monmouth.com!newscon02.news.prodigy.com!newsmst01.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr13.news.prodigy.com.POSTED!3bae8248!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Discrete random with given distribution ? References: <3D0F8880.2668FB86@despammed.com> X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 67.115.107.15 X-Complaints-To: abuse@prodigy.net X-Trace: newssvr13.news.prodigy.com 1024446861 ST000 67.115.107.15 (Tue, 18 Jun 2002 20:34:21 EDT) NNTP-Posting-Date: Tue, 18 Jun 2002 20:34:21 EDT Organization: Prodigy Internet http://www.prodigy.com X-UserInfo1: SCSYASVGXZUWSVPXN[O@_WH@YR_B@EXLLBWLOOAFMAVNDQUBLNTC@AWZWDXZXQ[K\FFSKCVM@F_N_DOBWVWG__LG@VVOIPLIGX\\BU_B@\P\PFX\B[APHTWAHDCKJF^NHD[YJAZMCY_CWG[SX\Y]^KC\HSZRWSWKGAY_PC[BQ[BXAS\F\\@DMTLFZFUE@\VL Date: Wed, 19 Jun 2002 00:34:21 GMT Xref: archiver1.google.com comp.lang.ada:26328 Date: 2002-06-19T00:34:21+00:00 List-Id: type ps is delta 0.001 range 0.0 .. 1000.0; for ps'small use 0.001; > > While a programmer would, of course, recognize the problem when he wrote > > "1.0/1024.0" and knew he was dealing with 3 digit accuracy, the problem > > could easily creep in if the Probability array was calculated at run time. > ... at how simple it _seemed_ to be when I actually wrote it out. I think all you need is type Probability_Type is delta 0.001 range 0.0 .. 1000.0; for Probability_Type'small use 0.001; ... -- add all the Probability(I) and then divide them by their sum -- to guarantee they all add to 1.0 even after rounding to 3 digits. In this example, of course, 1.0/1024.0 => 0.0 and the last Discrete_Type is chosen 100% of the time, which may or may not be desirable behavior.