🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.delphi.misc
Article #728

Re: Buffon's Needles

#728
From: David C. Ullrich
Date: Mon, 28 Jun 1999 00:00
134 lines
6239 bytes
In article <j+NWi+AgBrd3EwbC@merlyn.demon.co.uk>,
  Dr John Stockton <jrs@merlyn.demon.co.uk> wrote:
> JRS:  In article <7l61qb$u9u$1@nnrp1.deja.com> of Sun, 27 Jun 1999
> 20:33:15 in news:comp.lang.pascal.delphi.misc, David C. Ullrich
> <ullrich@math.okstate.edu> wrote:
> >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:
> >> >       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?
>
> Yes; but I took |P1 - P2| as the absolute value of the difference in
> each (X, Y) direction.

   Um, right. I won't ask what you thought the square root I mentioned
was...

    There _was_ an error in what I wrote yesterday, btw. Doesn't
look like you noticed.

> >    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;
>
> This chooses a point at random within a large square - then another.

      Huh?

> >//"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

     This is where the typo was. Replace the last two lines with

    until 0.25 < X*X + Y*Y < 1;
//the actual numbers 0.25 and 1 don't matter,
//except that of course the target annulus has to be
//a subset of the square we selected (X,Y) from.

> and select those within a circular relative annulus, so to speak.

    Right.

> >//"rescale" as suggested:
> >
> >    r:= sqrt(X*X + Y*Y);
> >    P2.X:= P1.X + X/r;
> >    P2.Y:= P1.Y + Y/r;
>
> No need to rescale just to get angles, of course; that was for getting
> needles.

     Right, I thought needles was what we wanted.

> >     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.)
>
> Yes, *that* should work - actually, ISTM that one could make P1 =
(0,0),
> randomly generate P2 = (X,Y) within a square around that, accept those
> P2 within the inscribed circle and not too near the centre, and use
> ATAN2(Y, X).
>
> BUT one is then selecting just a fraction Pi/4 of the points as within
> the circle, and comment matching my original comment on Method 2
applies
> (typo in that : for Pi/2 read Pi/4) to both of our versions -- as a
part
> of the whole Buffon, one is doing work substantially equivalent to an
> evaluation of Pi in relation to needle angle, before adding scatter of
> needle centre position.

     What is this obsession with _angles_??? You don't need to
calculate an _angle_ explicitly. You calculate the position of
the needle as above - no angles come into it. (Not explicitly.)

     If you _prefer_ to convert the position of the needle's
emndpoints to an angle, _then_ convert the angle back to needle
endpoints, and then complain about how there was a Pi implicit
in the conversion then that's up to you. But there's no need to
know the value of Pi in the version above - you're just going in
circles. As it were.

> It's still a good Web page - but one difference between real Buffonian
/
> Euclidean life and a computer is that real life has a precision-grade
> intrinsic absolute standard of angle, the Turn of 2 Pi radians,
whereas
> the computer must either have a number or an algorithm supplied.

      Simply not so. (Um, a machine needs to have an algorithm
supplied to do anything. But if you mean that the machine needs
an independent algorithm for the value of Pi, it's simply not so.)

> --
>  � John Stockton, Surrey, UK. jrs@merlyn.demon.co.uk /
JR.Stockton@physics.org �
>   Web <URL: http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms,
& links.
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Technical Details
Message-ID: <7l8a6m$mdk$1@nnrp1.deja.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
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> <7l61qb$u9u$1@nnrp1.deja.com> <j+NWi+AgBrd3EwbC@merlyn.demon.co.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10baee,d24982a2aa52a35f
X-Google-Attributes: gid10baee,public
X-Google-Thread: 10a7f1,d24982a2aa52a35f
X-Google-Attributes: gid10a7f1,public
X-Google-Thread: 105ac8,d24982a2aa52a35f
X-Google-Attributes: gid105ac8,public
X-Google-Thread: 10a726,d24982a2aa52a35f
X-Google-Attributes: gid10a726,public
From: David C. Ullrich <ullrich@math.okstate.edu>
Subject: Re: Buffon's Needles
Date: 1999/06/28
Message-ID: <7l8a6m$mdk$1@nnrp1.deja.com>
X-Deja-AN: 494811747
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> <7l61qb$u9u$1@nnrp1.deja.com> <j+NWi+AgBrd3EwbC@merlyn.demon.co.uk>
X-Http-Proxy: 1.0 x27.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: Mon Jun 28 17:08:49 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)