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-17 11:18:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!cpk-news-hub1.bbnplanet.com!news.gtei.net!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: <3D0E0B2B.67155BF9@despammed.com> X-Newsreader: Tom's custom newsreader Message-ID: <0JpP8.675$IT1.47623463@newssvr13.news.prodigy.com> NNTP-Posting-Host: 64.175.240.255 X-Complaints-To: abuse@prodigy.net X-Trace: newssvr13.news.prodigy.com 1024337852 ST000 64.175.240.255 (Mon, 17 Jun 2002 14:17:32 EDT) NNTP-Posting-Date: Mon, 17 Jun 2002 14:17:32 EDT Organization: Prodigy Internet http://www.prodigy.com X-UserInfo1: SCSYQN_@FS@[SPTX\JKXOFXBWR\HPCTL@XT^OBPLAH[\RWICYFWUQBKZQLYJX\_ITFD_KFVLUN[DOM_A_NSYNWPFWNS[XV\I]PZ@BQ[@CDQDPCL^FKCBIPC@KLGEZEFNMDYMKHRL_YYYGDSSODXYN@[\BK[LVTWI@AXGQCOA_SAH@TPD^\AL\RLGRFWEARBM Date: Mon, 17 Jun 2002 18:17:32 GMT Xref: archiver1.google.com comp.lang.ada:26170 Date: 2002-06-17T18:17:32+00:00 List-Id: > > Unfortunately, roundoff complicates it a bit. Consider: > > Size = 10 > > If size is ten, you're only asking for one digit of accuracy. Size = 10 was just a small example. Consider: Size : constant := 1000; type Discrete_Things is range 1 .. 50; Probability : constant array(Discrete_Things) of Float := (1 .. 49 => 1.0/1024.0, 50 => 1.0-49.0/1024.0); the first 49, 1000*(1.0/1024.0), will each round to 1 the 50th, 1000*(1.0-49.0/1024.0), rounds to 952. So, ignoring the roundoff problem, the simple algorithm will try to put 49+952= 1001 entries in Lookup, which only has room for 1000 entries. 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.