From: tmoran@acm.org
Subject: Re: Discrete random with given distribution ?
Date: Mon, 17 Jun 2002 18:17:32 GMT
Date: 2002-06-17T18:17:32+00:00 [thread overview]
Message-ID: <0JpP8.675$IT1.47623463@newssvr13.news.prodigy.com> (raw)
In-Reply-To: 3D0E0B2B.67155BF9@despammed.com
> > 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.
next prev parent reply other threads:[~2002-06-17 18:17 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-13 12:10 Discrete random with given distribution ? Reinert Korsnes
2002-06-13 13:35 ` Larry Kilgallen
2002-06-13 12:49 ` Reinert Korsnes
2002-06-13 14:25 ` Wes Groleau
2002-06-13 16:10 ` Kevin Rigotti
2002-06-13 16:33 ` Jeffrey Carter
2002-06-13 22:23 ` Wes Groleau
2002-06-14 8:01 ` Gautier
2002-06-13 18:01 ` tmoran
2002-06-14 7:20 ` Reinert Korsnes
2002-06-14 18:49 ` Wes Groleau
2002-06-14 21:12 ` tmoran
2002-06-16 22:12 ` Wes Groleau
2002-06-17 5:01 ` tmoran
2002-06-17 16:15 ` Wes Groleau
2002-06-17 18:17 ` tmoran [this message]
2002-06-18 19:22 ` Wes Groleau
2002-06-19 0:34 ` tmoran
2002-06-19 0:53 ` tmoran
2002-06-19 5:13 ` Robert I. Eachus
2002-06-14 10:01 ` Gautier
-- strict thread matches above, loose matches on Subject: below --
2002-06-14 22:56 Gautier direct_replies_not_read
2002-06-14 23:10 ` tmoran
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox