comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: Discrete random with given distribution ?
Date: Thu, 13 Jun 2002 16:33:19 GMT
Date: 2002-06-13T16:33:19+00:00	[thread overview]
Message-ID: <3D08C94B.A50AECFE@acm.org> (raw)
In-Reply-To: 3D08AB63.6AF60F95@despammed.com

Wes Groleau wrote:
> 
>    Threshold : array (Out_Type) of Float :=
>      (A => 0.50,
>       B => 0.75,   -- previous plus Probability (B)
>       C => 1.00);  -- previous plus Probability (C)
> 
>    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;

This can never return C. F <= 1.0, and for many generators, F < 1.0.
Also, if F = 0.9, this returns A.

I suspect you need

F < Threshold (I)

-- 
Jeff Carter
"Oh Lord, bless this thy hand grenade, that with it thou
mayst blow thine enemies to tiny bits, in thy mercy."
Monty Python and the Holy Grail



  parent reply	other threads:[~2002-06-13 16:33 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 [this message]
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
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