You could slow down the faster of the two.

On 4/3/06, Sashikanth Chandrasekaran <[EMAIL PROTECTED]> wrote:
...

> Assume that I do not know the distributions of p1, p2
> in advance. Is there a way I can get consistent avg.
> performance (i.e. 6!:2 'p1 V p2' = approx. 6 seconds
> and 6!:2 'p2 V p1' = approx. 6 seconds).
>

Seriously, this seems like a case where knowing more context would help.
For instance, to take a simplified version of your problem, if we have

   p1=. 1 2 3 4
   p2=. 2 3 4 5 6

and we want to find

   (p1 e. p2);p2 e. p1
+-------+---------+
|0 1 1 1|1 1 1 0 0|
+-------+---------+

something like

   r3=. 0,2=/\(ord=. \:p1,p2){p1,p2
   r3,ord,(ord>#p1),:ord<:#p1
0 0 0 1 0 1 0 1 0
8 7 3 6 2 5 1 4 0
1 1 0 1 0 1 0 0 0
0 0 1 0 1 0 1 1 1

has all the data to construct an answer but may run much more quickly.
E.G. construct large versions of p1 and p2 with distributions similar to
Sashi's example:
   nn=. 999
   #~.p2=. 48730$~.(<?nn$0){~&.>?&.>(([: >: [: ? ])&.>50000$100)$&.><nn
48730
   #~.p1=. 13930$(14000?48980){p2,(<?nn$0){~&.>?&.>(([: >: [: ?
])&.>250$100)$&.><nn
13930
   NB. Arbitrary numbers above are: 48980 = 48730+250 and 0.99489588 =
48730%48980

   (%/,])(6!:2 'r1 =. p1 e. p2'),6!:2 'r2 =. p2 e. p1'
2.2350347 2.7715173 1.2400332     NB. Ratio of timings, timings for r1 and
r2
   6!:2 'r3=. 0,2=/\(ord=. \:p1,p2){p1,p2'   NB. Faster way to get
equivalent info?
0.27696538
   ((+/r1) % #p1),(+/r2) % #p2
0.99475951 0.28436282     NB. p1 is 99.47% the same as p2 which is 28.4% the
same as p1

Good luck,

Devon
--
Devon McCormick
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to