• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Meaningles drivel about random points in a circle (and Bertrands paradox)

 
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The other day I was watching one of those brilliant 3blue1brown-youtubies, where the man talked about Bertrands paradox. That paradox is about an equilateral triangle and its surrounding circle, and the question is: what is the chance that a random chord of this circle has lenght greater that the side of that triangle?

Bertrand (a French mathematician) gave a few very convincing ways to determine that chance, and in each case he got a different outcome.

For instance: method 1 was choosing a point on the circle, such that that point is also a vertex of the triangle. It is then easy to see that the chance is 1/3.

Method 2 involves taking a radius of the circle, such that that radius is perpendicular to one of the triangles sides. If we pick a random point on this radius and take the chord through this point that is perpendicular to the radius, then it is easy to see that the chance is 1/2.

Huh?

Reading Wikipedia (Dutch version) about this, it stated that that paradox is not a paradox at all, since it is not defined how one would choose a random chord. Now, the English version is a lot more detailed, as I noticed later, but that made me curious. What exactly was that difference between method one and method 2? After some thinking (at the cost of some nightrest) it occurred that in method 1 you can choose the second point freely: any point on the circle it just as likely as any other point. In method 2, however, choosing a random point on that radius, and looking at the corresponding point on the circle, we see that we do not get equal likely points on that circle! For points lying on the right half of the radius, the corresponding point on the circle will be on 2/3 of the quartercircle above, and for points on left half of the radius, we would get 1/3 of the quartercircle above. So, we do not get equal-likely points on the circle.

Pfff.

That gave me the idea of drawing random points within a given circle. Now, an obvious method is: choose a random length r from 0 to the radius, choose a random angle a between 0 and 2PI, and draw the point (r, a) (in polar coordinates). However, this gives a problem: if we divide the circle in two parts: circle A with half of the radius, and B being the rest of the circle, then half the points will end up in A, and half the points will end up in B. But B's surface is three times as large as A's surface, so A will look more dense than B. How can we choose a random length r such that we will get a uniform coverage of the circle? To get a uniform coverage, it seems that if we choose two radii r1 > r2, then the circle with r1 should get more points than the circle with r2, probably in the ratio of the circumference of both. So, a promising candidate for choosing a length r is having the distribution f(r) = alpha * r, for values between 0 and 1. And to get a proper distribution, it is easy to see that alpha should be 2.

So, to choose a length between 0 and 1, we use the distribution with cdf F(x) = x^2.
To get samples from such a distribution, we proceed as follows: draw the graph of F(x), and choose a point y with y = random.nextDouble(). Go from the point (0, y) horizontally until we intersect with the graph of F(x). For that point of intersection, we have that that point is (x, y) for some value of x, but it is also the point (x, F(x)), and since F(x) = x^2, we see that y = x^2, giving x = sqrt(y). In other words: we deterime some value y with y = random.nextDouble(), and take as length sqrt(y).

To see the outcome of all this, I made a little program that shows four circles, full of random points. The upper left shows points for which the length was determined with random.nextDouble, and upper right where the lengths are choosen from the distribution that I described above.

At the bottom, I repeated the process, albeit I now used a discrete version of the distribution above, with 10 different radii.
The discrete distribution for the bottom right is:

P[radius = i] = i / 55, for i = 1, ... 10.

And to answer your question: do you really have nothing better to do? Well, now I have, 'cause the mrs just ordered me to to the vacuum cleaning.
 
reply
    Bookmark Topic Watch Topic
  • New Topic