Ric,
Terrific analysis and results. Thank you.
Again and again I noticed subtle changes you made
and truly enjoyed finding and digesting them.
I was penning a reply to your first message when I
noticed the further revision you noticed here regarding the
revisions needed for an array argument. And using $ in
place of {. makes so much more sense. Bravo, again.
Btw, I noticed that your timing here regarding the
replacement of -@:+: with _2&* reflects my experience:
sometimes there is an improvement, but often there is a
slight deterioration in timing.
On Wed, 13 Aug 2008, Sherlock, Ric wrote:
+ ---Brian Schott wrote:
+ > The original normalrand does NOT produce (a,b) pairs
+ > of variates, but all the others do produce the variates in
+ > pairs. The others produce (a,b) pairs of random varates in
+ > different orders, they all produce valid pairs of variates.
+
+ I've just worked out the thing that normalrand does that the others don't:
+
+ normalrand 3 4
+ _0.122699 _1.99223 _0.704035 _0.0808088
+ _0.250496 0.48138 0.764205 _0.794871
+ 1.45207 _0.696283 _0.453133 1.01379
+
+ normalrand2 3 4
+ _1.66701 _0.640152 0 0
+ 0.94087 _0.588251 0 0
+ 1.0616 _0.662911 0 0
+
+ normalrand6a 3 4
+ |length error: normalrand6a
+ | normalrand6a 3 4
+
+ Some small alterations fix that:
+ normalrand2a=: 3 : 0
+ n =. >. -: */y
+ a=. %: _2* ^. rand01 n
+ b=. +: o. rand01 n
+ r1 =. a * 2 o. b
+ r2 =. a * 1 o. b
+ y$r1,r2
+ )
+
+ normalrand6b=: ] $ ,@((2 1 o."0 1 +:@:o.@:rand01) *"1 [: %:
_2&*@:^.@:rand01)@>[EMAIL PROTECTED]:@(*/)
+
+ normalrand2a 3 4
+ 0.63111367 1.3648031 _0.68584133 _0.74547942
+ _0.63025564 _1.4558397 _1.8241795 0.22040767
+ _0.49059304 1.8463946 _0.45497306 1.3861815
+ normalrand6b 3 4
+ 0.67241889 0.95258629 _1.2074204 0.058530861
+ 0.64824598 0.93121615 0.62299124 0.33683066
+ _1.3331847 _0.57881303 _0.45320203 0.44516874
+
+ 10 ts 'normalrand numb'
+ 0.024500181 10488320
+ 10 ts 'normalrand2 numb'
+ 0.017422885 4196608
+ 10 ts 'normalrand2a numb'
+ 0.017089022 4196608
+ 10 ts 'normalrand6a numb'
+ 0.016773354 2622592
+ 10 ts 'normalrand6b numb'
+ 0.017133078 2622656
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm