Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: Notesfiles $Revision: 1.7.0.8 $; site convex
Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!inuxc!pur-ee!uiucdcs!convex!bjchrist
From: bjchrist@convex.UUCP
Newsgroups: net.sources
Subject: Re: Solving Pi
Message-ID: <42500016@convex>
Date: Mon, 19-Aug-85 14:51:00 EDT
Article-I.D.: convex.42500016
Posted: Mon Aug 19 14:51:00 1985
Date-Received: Sat, 24-Aug-85 03:36:09 EDT
References: <187@ski.UUCP>
Lines: 21
Nf-ID: #R:ski.UUCP:-18700:convex:42500016:000:947
Nf-From: convex.UUCP!bjchrist    Aug 19 13:51:00 1985


As an aside: If you know PI you can check a random number generator by the
	accuracy with which it calculates pi by the following means:

	|a square with coordinates: (0,0) (1,0) (1,1) (0,1) has an area
	|of one (1)
	|
given:	|a circle with radius 1 has as its area PI. Plot the circle on graph
	|paper with is center at (0,0). The area of the circle falling
	|in quadrant 1 is PI/4. So the ratio of points within the square's
	|area AND within the circle's area is PI/4.

	write a program to generate two random numbers 0<= x <= 1.0
	keep count of the number of times sqrt(x**2 + y**2) <=1.0

	the ratio of the hits (sqrt(x^2 + y^2) <= 1.0) to misses will give
	you PI/4. The rate of convergence is horrible but it's interesting
	to compare random number generators and their accuracy. If a
	REAL *random* number generator is used. After an infinite number
	of shots, you will really have PI. Assuming you have an infinitly
	accurate calculator.