Article View: comp.lang.pascal.delphi.misc
Article #725Re: Buffon's Needles
From: David C. Ullrich
Date: Sun, 27 Jun 1999 00:00
Date: Sun, 27 Jun 1999 00:00
88 lines
4150 bytes
4150 bytes
In article <3zADx9AXVWd3EwJU@merlyn.demon.co.uk>,
Dr John Stockton <jrs@merlyn.demon.co.uk> wrote:
> JRS: In article <7l357k$4m6$1@nnrp1.deja.com> of Sat, 26 Jun 1999
> 18:13:14 in news:comp.lang.pascal.delphi.misc, David C. Ullrich
> <ullrich@math.okstate.edu> wrote:
> >In article <zZIi7jAzW8c3EwDD@merlyn.demon.co.uk>,
> > Dr John Stockton <jrs@merlyn.demon.co.uk> wrote:
>
> > I have no idea what a "subset-capability" is, but modulo
> >that of course there is. Set one endpoint P1 of the needle to a
> >random point in a large square. Then set the other endpoint
> >to another random point. Reject the second endpoint until you
> >get one with say 0.5 < |P1 - P2| < 2. Then rescale it so
> >|P1 - P2| = 1. There's your random needle, no trig and hence
> >no Pi required.
> >
> > ("rescale": say P2 := P1 + (P2 - P1)/|P2 - P1| . No
> >angles, just a square root.)
>
> ISTM, seemingly confirmed by test, that your method does not give a
> uniform distribution of angles.
If so then you're trying something other than what I suggested.
Did you read all of it or just a few sentences?
Psuedocode (note these are all real variables, converting to
integers too soon would be bad):
//"Set [...] P1 [...] to a random
//point in a large square":
N:= LargeNumber;
P1.X:= N*random;
P1.Y:= N*random;
//"Then set the other endpoint
//to another random point. Reject the second endpoint until you
//get one with say 0.5 < |P1 - P2| < 2":
repeat
X:= 1 - 2*random;
Y:= 1 - 2*random;
until 0.25 < X*X + Y*Y < 4;
//the actual numbers 0.25 and 4 don't matter
//"rescale" as suggested:
r:= sqrt(X*X + Y*Y);
P2.X:= P1.X + X/r;
P2.Y:= P1.Y + Y/r;
If you don't get a uniform distribution of angles from
lemme know and I'll make an actual compilable version (if the
RNG is worse than I thought it won't work, of course. But I
didn't think the RNG was _that_ bad.)
> >> It must be better still to glue large numbers, evenly distributed
in
> >> angle, together - centrally to get a disc, or endwise to get a
ring.
> >> Not too many, though; with an infinite number of needles, unless
> >> carefully treated, there's a risk of getting infinity/infinity as
the
> >> result.
> >
> > Huh? The limit in question _is_ a limit "of the form
> >infinity/infinity". I don't think there's much danger of
> >the actual algorithm running infinitely many times.
>
> With an infinite number of needles glued together, the algorithm need
> only be run once - though this will take infinite time.
Aha.
> --
> � John Stockton, Surrey, UK. jrs@merlyn.demon.co.uk Turnpike v4.00
MIME. �
> Web <URL: http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms,
& links.
> Correct 4-line sig. separator is as above, a line precisely "-- "
(SoRFC1036)
> Do not Mail News to me. Before a reply, quote with ">" or "> "
(SoRFC1036)
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Technical Details
Message-ID:
<7l61qb$u9u$1@nnrp1.deja.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7ks8ls$mgk$1@bgtnsc03.worldnet.att.net> <Im0c0MABmjc3Ew2K@merlyn.demon.co.uk> <zZIi7jAzW8c3EwDD@merlyn.demon.co.uk> <7l357k$4m6$1@nnrp1.deja.com> <3zADx9AXVWd3EwJU@merlyn.demon.co.uk>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10a726,d24982a2aa52a35f X-Google-Attributes: gid10a726,public X-Google-Thread: 10a7f1,d24982a2aa52a35f X-Google-Attributes: gid10a7f1,public X-Google-Thread: 10baee,d24982a2aa52a35f X-Google-Attributes: gid10baee,public X-Google-Thread: 105ac8,d24982a2aa52a35f X-Google-Attributes: gid105ac8,public From: David C. Ullrich <ullrich@math.okstate.edu> Subject: Re: Buffon's Needles Date: 1999/06/27 Message-ID: <7l61qb$u9u$1@nnrp1.deja.com> X-Deja-AN: 494511936 References: <7ks8ls$mgk$1@bgtnsc03.worldnet.att.net> <Im0c0MABmjc3Ew2K@merlyn.demon.co.uk> <zZIi7jAzW8c3EwDD@merlyn.demon.co.uk> <7l357k$4m6$1@nnrp1.deja.com> <3zADx9AXVWd3EwJU@merlyn.demon.co.uk> X-Http-Proxy: 1.0 x33.deja.com:80 (Squid/1.1.22) for client 139.78.112.79 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Sun Jun 27 20:33:15 1999 GMT Newsgroups: comp.lang.pascal.delphi.misc,alt.comp.borland-delphi,de.comp.lang.pascal.delphi,fr.comp.lang.pascal X-Http-User-Agent: Mozilla/4.5 [en] (Win95; U)