I'm trying to run a simulation, where I generate a series of states
(deals of a hand of cards, series of dierolls, etc) and then calculate
stats for that series (i.e. a histogram of "scores", where the score
is calculated by a user-defined function). This works fine when I can
generate an array of all the states at once - something like

5 ? (1000000 # 52)

for a million 5-card deals from a deck of cards. But it runs out of
memory when I start getting to tens or hundreds of millions of
samples. Whet I'd like to do in that situation is to run the
calculations in batches of (say) a million at a time, and accumulate
the results. But what I can't see is an obvious way of saying "run
this calculation 10 times, regenerating the random numbers each time"
without using an explicit loop.

To be explicit, a similar but simpler problem would be to generate six
deals of 5 cards, by generating 3 deals twice:

   (5?3#52), (5?3#52)
28  7 24 39  6
46 36  0 26  1
14 23 26 47 50
30 26  7  5 16
47  8 23 34 26
31 35 40 50 32

Is there a way of writing this where I can abstract (5?3#52) out, and
only write it once? Something like "two_sets_of (5?3#52)" for some
defined sets_of? The simple definition

   two_sets_of =: monad : 'y, y'

won't work because the same set of 3 rolls is used twice, rather than
2 independent sets of rolls.

Thanks,
Paul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to