Given a mapping between items and their required probability of occurrence, generate a million items randomly subject to the given probabilities and compare the target probability of occurrence versus the generated values.

The total of all the probabilities should equal one. (Because floating point arithmetic is involved, this is subject to rounding errors).

aleph   1/5.0
beth    1/6.0
gimel   1/7.0
daleth  1/8.0
he      1/9.0
waw     1/10.0
zayin   1/11.0
heth    1759/27720 # adjusted so that probabilities add to 1
Related task

 Random number generator (device)


/*REXX program displays results of probabilistic choices, gen random #s per probability.*/
parse arg trials digs seed .                     /*obtain the optional arguments from CL*/
if trials=='' | trials==","  then trials= +1e6   /*Not specified?  Then use the default.*/
if   digs=='' |   digs==","  then   digs=   15   /* "      "         "   "   "     "    */
if datatype(seed, 'W')  then call random ,,seed  /*allows repeatability for RANDOM nums.*/
numeric digits digs                              /*use a specific number of decimal digs*/
names= 'aleph beth gimel daleth he waw zayin heth ───totals───►'   /*names of the cells.*/
hi= 100000                                                         /*max REXX RANDOM num*/
z= words(names);             #= z - 1            /*#: the number of actual/usable names.*/
$= 0                                             /*initialize sum of the probabilities. */
           do n=1  for #;    prob.n= 1 / (n+4);     if n==#  then prob.n= 1759 / 27720
           $= $ + prob.n;   Hprob.n= prob.n * hi /*spread the range of probabilities.   */
           end   /*n*/
prob.z= $                                        /*define the value of the ───totals───.*/
@.= 0                                            /*initialize all counters in the range.*/
@.z= trials                                      /*define the last counter of  "    "   */
           do j=1  for trials;    r= random(hi)  /*gen  TRIAL  number of random numbers.*/
               do k=1  for #                     /*for each cell, compute  percentages. */
               if r<=Hprob.k  then @.k= @.k + 1  /* "    "    "  range, bump the counter*/
               end   /*k*/
           end       /*j*/
_= '═'                                           /*_:  padding used by the  CENTER  BIF.*/
w= digs + 6                                      /*W:  display width for the percentages*/
d= 4 + max( length(trials), length('count') )    /* [↓]  display a formatted top header.*/
say center('name',15,_)  center('count',d,_) center('target %',w,_) center('actual %',w,_)
 
     do cell=1  for z                            /*display each of the cells and totals.*/
     say  ' '   left( word(names, cell), 13)             right(@.cell, d-2)  " " ,
                left( format(   prob.cell   * 100, d),   w-2) ,
                left( format( @.cell/trials * 100, d),   w-2)   /* [↓]  foot title. [↓] */
     if cell==#  then say  center(_,15,_)   center(_,d,_)    center(_,w,_)   center(_,w,_)
     end   /*c*/                                 /*stick a fork in it,  we are all done.*/