There are other situations where the expression I suggested is much more economical than the one you used. For example:
ts=: 6!:2 , 7!:2...@] 10 ts '1e6 ?...@$ 2' 0.0029846 1.04934e6 10 ts '?1e6 $ 2' 0.0132888 5.24352e6 i.e. factor of 4 in time, factor of 5 in space. ----- Original Message ----- From: Don Guinn <[email protected]> Date: Sunday, April 25, 2010 7:53 Subject: Re: [Jprogramming] Random Numbers with interation To: Programming forum <[email protected]> > True. There is a lot that could be done to make it faster. But > it was so > much faster I didn't bother. And as you say, if you can't half > the time, > it's not worth doing. But I did try it. Looks like maybe 20% faster > > On Sun, Apr 25, 2010 at 9:18 AM, Roger Hui <[email protected]> wrote: > > > Slightly more economical to do 1...@#50 or 1...@$50 > > instead of ?1e6#50 . > > > > > > > > ----- Original Message ----- > > From: Don Guinn <[email protected]> > > Date: Sunday, April 25, 2010 5:57 > > Subject: Re: [Jprogramming] Random Numbers with interation > > To: Programming forum <[email protected]> > > > > > How about 0.07 seconds. > > > > > > 6!:2 '(1!:2&2)|."1]10{.\:~(>:~.z),.~ > #/.~z=.?1e6#50'> > 15 20400 > > > 8 20340 > > > 46 20287 > > > 13 20278 > > > 33 20249 > > > 39 20220 > > > 18 20219 > > > 29 20206 > > > 25 20197 > > > 9 20166 > > > 0.0658392 > > > > > > On Sun, Apr 25, 2010 at 7:36 AM, smandula > > > <[email protected]> wrote: > > > > > > > > > > > Thank you kindly for your reply. > > > > The statement of one million is an example, could be > > > 1,000 or 50,000 > > > > iterations. > > > > The random numbers being tested could be 1 to 50, or 1 to 100 > > > > > > > > I have a basic program whereby I enter the maximum iterations, > > > in the > > > > example 1,000,000 > > > > and a time clock starts, and a counter starts counting up to > > > the required > > > > 1,000,000 intervals. > > > > > > > > Once, done the time duration shows, in my case 17 minutes, and > > > a list of 10 > > > > highest occurrences > > > > for these random numbers. i.e. > > > > number 29 occurrences 204,984 > > > > number 26 occurrences 204,855 > > > > number 40 occurrences 204,732 > > > > number 17 occurrences 204,629 > > > > Number 1 occurrences 204,480 > > > > > > > > I would appreciate any input from the forum, especially for > > > faster times ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
