Roger, thank you.
As Roger guessed, it looks to me as if there is an
improvement using I. . In my modest tests the improvement
is of approximately 3+ times in speed as well as an
improvement in space. My suggested revision in discreterand,
named discreterand2, is below.
With my very primitive time testing, I was unable to
achieve any distinction between inputs such as the two
inputs below, named data and data1 with either discreterand
or discreterand2. If my tests are correct then /: and I.
both appear to obviate the need for being careful about the
order of presenting inputs.
data =: 4000;~ 2 3$2 3 4 0.05 0.05 0.9
data1 =: 4000;~|."1]2 3$2 3 4 0.05 0.05 0.9
discreterand2=: 3 : 0
'm n'=. y
'v p'=. m
f=. +/\p%+/p
v {~ f I. rand01 n
)
On Tue, 12 Aug 2008, Roger Hui wrote:
+ It is best to do timings to see which would be faster,
+ because different algorithms are used within /: and I.
+ depending on the data, and order of complexity
+ ("big O") considerations are not precise enough
+ for this kind of comparison. My guess is that
+ x I. y is going to be faster than /:x,y most of the time.
+
+ x=: /:~ 20 [EMAIL PROTECTED] 0
+ y=: 1e4 [EMAIL PROTECTED] 0
+ ts 'x I. y'
+ 0.000896483 66112
+ ts '/:x,y'
+ 0.00582644 262720
+
+
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm