R&S HUI:
So why are the numbers uniform?
First, y is converted to a number base x (n digit vector) 0&{ is highest
"digit", _1&{ is the "lowest". Then we genereate an n-"digit" random number
in
a range 0.._1+x^n and if it is less than y we keep it and if it >:y we drop
it
and start over. Assuming uniform and independent distribution of random
"digits" we get uniformly distributed result. The way we generate and check
digits promises uniformly finite average number of discarded digits per
result (I
estimate this limit to be either 1 or 2).
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm