Just back from doing a BBC Prom!  Very loud...  Still some
voice left.

If I'm doing a simulation,  I often do ? on a large sample,
eg ?1000000#1000 or the like,  and then "draw" from that
sample in sequence.   Usually for independent trials.

For example,  for this donation problem,  it _might_ be
preferable to sample ?10000 400$400 and then work down
the 10000 rows than doing the ^:10000 trick.   (The trials
are still independent,  assuming you're happy to sample
even for the non-donors.)

I haven't tried that approach here,  so don't know off hand
whether it's worth trying.

Cheers,
Mike

On 27/07/2017 21:27, Jimmy Gauvin wrote:
I was wondering if making rg tacit would boost performance.
Thanks to Raul for answering my unvoiced question.

I guess key, nub and amend are well optimized in the J interpreter.

Jimmy

PS Is roll also optimized for speed? If not should we look into ISAAC or
other fast PRNGs?



On Thu, Jul 27, 2017 at 5:23 AM, Raul Miller <rauldmil...@gmail.com> wrote:

Ah, i was testing it on too small of a data set.

Thanks,

--
Raul


On Thu, Jul 27, 2017 at 4:33 AM, 'Mike Day' via Programming
<programm...@jsoftware.com> wrote:
Jimmy's original rg outperforms both tock and the best of
my various attempts at "new" for "larger" problems,  eg

    10 ts 'rg^:10000 #~400'
0.633403 38272
    10 ts 'tock^:10000 #~400'
0.751826 34816
    10 ts 'new^:10000 #~400'
0.793394 39424

NB. less good on smaller ones
    30 ts 'rg^:10000 #~10'
0.10968 6784
    30 ts 'tock^:10000 #~10'
0.0662844 3840
    30 ts 'new^:10000 #~10'
0.0633482 3968

(Have you looked at Raul's results table, posted on 20/7?)

The original problem asked us to consider 100 players,
but, as usual,  it's one thing to solve a small puzzle that you
can get your head round,  but very often a much more challenging
requirement to get it to scale up.

Those many Project Euler problems are worth looking at with
scale of application in mind.     ( //projecteuler.net )

Thanks,
Mike



On 27/07/2017 05:54, Raul Miller wrote:
Oh, well, you could make it tacit. For example:

     rg=:(((#/.~@])`(~.@])`(0*[)} +/?@##)+-) *

That does not speed it up, though.

Anyways, good luck,


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

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

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

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

Reply via email to