Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!torn!cs.utexas.edu!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!mm-mac23.mse.uiuc.edu!gaylord
From: Richard J. Gaylord <gaylord@ux1.cso.uiuc.edu>
Subject: Re: (gradeup N roll N) is not (N deal N)
Date: Wed, 10 Feb 1993 09:36:44 GMT
X-Xxmessage-Id: <A79E28F322019B17@mm-mac23.mse.uiuc.edu>
X-Useragent: Nuntius v1.1.1d13
Message-ID: <C28819.5so@news.cso.uiuc.edu>
References: <930210012341_70530.1226_DHP31-1@CompuServe.COM>
Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
X-Xxdate: Wed, 10 Feb 93 03:37:23 GMT
Organization: University of Illinois
Lines: 52

Subject: (gradeup N roll N) is not (N deal N)
From: Mike Kent, 70530.1226@CompuServe.COM
Date: Wed, 10 Feb 1993 01:23:42 GMT
In article <930210012341_70530.1226_DHP31-1@CompuServe.COM> Mike Kent,
70530.1226@CompuServe.COM writes:
>In article <C258LB.1qw@news.cso.uiuc.edu>, Richard J. Gaylord
><gaylord@ux1.cso.uiuc.edu> proposes the "deal" algorithm:

> >>  chooseHistory2[lis_, n_] :=
> >>     Take[Transpose[Sort[Transpose[{Table[Random[], {Length[lis]}],
> >>        lis}]]] [[2]], n]
>
>This is _not_ the same as APL deal, since it does not generate all
>permutations equiprobably.  This is easiest to see for the case where
>"lis" is (1 2) and "n" is two, where it clearly amounts to producing
>(1 2)[gradeup ?2 2], which is just (origin 1)   gradeup ?2 2  .  But
>?2 2   produces with equal probability (1 1), (1 2), (2 1), and (2 2),
>and gradeup produces (1 2), (1 2), (2 1), and (1 2) for these vectors,
>so the quoted algorithm will produce (1 2) 75% of the time.  

==========
i may be missing the point here. the algorithm is  non-deterministic so
the only way to see what it produces is to to run it. i did and here are
the results: 

chooseHistory2[lis_, n_] :=
    Take[Transpose[Sort[Transpose[{Table[Random[], {Length[lis]}],
lis}]]] [[2]], n]

-----------------
just out testing lis = {a, b} and n = 2

Table[chooseHistory2[{a, b}, 2], {5}]
{{a, b}, {b, a}, {a, b}, {b, a}, {b, a}}

---------
now doing runs of 500, 1000, 5000 and 10000:


Count[Table[chooseHistory2[{a, b}, 2], {500}], {a, b}]
255

Count[Table[chooseHistory2[{a, b}, 2], {1000}], {a, b}]
463

Count[Table[chooseHistory2[{a, b}, 2], {5000}], {a, b}]
2512

Count[Table[chooseHistory2[{a, b}, 2], {10000}], {a, b}]
4995

this looks pretty close to 50:50. am i misunderstanding sonething here?
