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 11:02:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.cwix.com!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: <3D08AB63.6AF60F95@despammed.com> X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 64.175.241.254 X-Complaints-To: abuse@prodigy.net X-Trace: newssvr13.news.prodigy.com 1023991303 ST000 64.175.241.254 (Thu, 13 Jun 2002 14:01:43 EDT) NNTP-Posting-Date: Thu, 13 Jun 2002 14:01:43 EDT Organization: Prodigy Internet http://www.prodigy.com X-UserInfo1: [[PAPDCA[S@[SPTX\JKXOFXBWR\HPCTL@XT^OBPLAH[\RSAANVUEAE[YETZPIWWI[FCIZA^NBFXZ_D[BFNTCNVPDTNTKHWXKB@X^B_OCJLPZ@ET_O[G\XSG@E\G[ZKVLBL^CJINM@I_KVIOR\T_M_AW_M[_BWU_HFA_]@A_A^SGFAUDE_DFTMQPFWVW[QPJN Date: Thu, 13 Jun 2002 18:01:44 GMT Xref: archiver1.google.com comp.lang.ada:25897 Date: 2002-06-13T18:01:44+00:00 List-Id: > type Rand_Val is (A1, A2, B, C); > > Lookup : array (Rand_Val) of Out_Type := > (A1 => A, > A2 => A, > B => B, > C => C); > > package Rand is > new Ada.Numerics.Discrete_Random (Rand_Val); > > .... > > return Lookup (Rand.Random (Gen)); >The first is awkward if the probabilities are complicated. If your probabilites are expressed with three digit accuracy, for instance, just make a 1000 element Lookup table with the right number of A's, B's, and C's at initialization time. Few probabilities are more precise than that. (If they appear to be, .3333... for instance, create Lookup with an appropriate LCM size other than a power of ten.)