Newsgroups:   comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!torn!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!newsserver.jvnc.net!howland.reston.ans.net!gatech!rpi!utcsri!geac!jtsv16!itcyyz!yrloc!intern
From:         loc@yrloc.ipsa.reuter.COM (Leigh Clayton)
Subject:      Re:      cup of coffee
Message-ID: <1993Feb16.174821.20849@yrloc.ipsa.reuter.COM>
Sender: intern@yrloc.ipsa.reuter.COM (Intern via QUADRAM)
X-Telephone:  +1 (416) 364-5361 Fax +1 (416) 364-2910 Telex 0622259
Organization: Reuters APL Software Division
X-Mail:       1900/2 First Canadian Place, Toronto, Canada, M5X 1E3
Date:         16 Feb 93 17:02:53 UT
Lines: 42

 sippy+@CS.CMU.EDU (Jay Sipelstein) responds to Eugene McDonnell:

 - 1. Your algorithm is incorrect.  As you say, there is a bias from
 -    repetitions, so that you're not sampling the space of permutations
 -    uniformly, as is required by deal. (At least, according to my APL
 -    manual.)
 - 2. It doesn't run in linear time.  I assume you're claiming that the grade
 -    operation is linear, because it is implemented as a bucket sort of
 -    some kind.  However, the number of passes over the data you make in
 -    the bucket sort is proportional to the number of bits in each of the
 -    values, ie, is logarithmic in the input.  In this case, the input is
 -    bounded by 1e9, so you require a constant number of passes.  However,
 -    this places a limitation on the number of elements you can deal,
 -    especially in light of the inaccurate distribution.  It doesn't make
 -    much sense to talk about complexity when you have a maximum size input.
 -
 - Doesn't seem so smart to me.
 -

 You're really being quite unfair to Eugene. Both your criticisms are strictly
accurate, but neither was greatly relevant when Eugene wrote the code. In the
early days of APL\360, workspaces were (often much) less than 32K and so the
arrays being used were very small compared to 1e9. This makes the perterbation
of the distribution due to repetitions basically unmeasurable (remember, roll
isn't really random anyway - pseudorandomness is only 'random' within certain
limitations). And while grade certainly isn't linear, it's non-linearity
doesn't intrude strongly for smallish arrays. The idea, really, is to avoid
lengthy or even endless iterations in the APL code, and Eugene's code certainly
achieves that in an effective and interesting way.

 I agree that it wouldn't make a good method for an implementation of roll in a
modern APL interpreter, though.

.../Leigh

--------------------------------------------------------
 Make haste, therefore, sweet love, whilest it is prime
 For none can call again the passed time.
                 Edmund Spenser
--------------------------------------------------------
Leigh Clayton                  loc@yrloc.ipsa.reuter.COM
    -or-                     loc@ipsalab.ipsa.reuter.COM
