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)


 
main=: verb define
  hdr=.  '       target   actual  '
  lbls=. ; ,:&.> ;:'aleph beth gimel daleth he waw zayin heth'
  prtn=. +/\ pt=. (, 1-+/)1r1%5+i.7
  da=.   prtn I. ?y # 0
  pa=.   y%~ +/ da =/ i.8
  hdr, lbls,. 9j6 ": |: pt,:pa
)
 
Note 'named abbreviations'
     hdr  (header)
     lbls (labels)
     pt   (target proportions)
     prtn (partitions corresponding to target proportions)
     da   (distribution of actual values among partitions)
     pa   (actual proportions)
)