March 19, 2011
By

(This article was first published on Xi'an's Og » R, and kindly contributed to R-bloggers)

Some may have had reservations about the “randomness” of the straws I plotted to illustrate Bertrand’s paradox. As they were all going North-West/South-East. I had actually made an inversion between cbind and rbind in the R code, which explained for this non-random orientation. Above is the corrected version, which sounds “more random” indeed. (And using wheat as the proper, if weak, colour!) The outcome of a probability of 1/2 has not changed, of course. Here is the R code as well:

```lacorde=rep(0,10^3)
plot(0,0,type="n",xlim=c(-2,2),ylim=c(-2,2))

for (t in 1:10^3){

#distance from O to chord
dchord=10

while (dchord>1){
#Generate "random" straw in large box till it crosses unit circle

a=runif(2,-10,10)
b=runif(2,-10,10)

#endpoints outside the circle
if ((sum(a^2)>1)&&(sum(b^2)>1)){

theta=abs(acos(t(b-a)%*%a/sqrt(sum((b-a)^2)*sum(a^2))))
theta=theta%%pi
thetb=abs(acos(t(a-b)%*%b/sqrt(sum((b-a)^2)*sum(b^2))))
thetb=thetb%%pi

#chord inside
if (max(abs(theta),abs(thetb))
As a more relevant final remark, I came to the conclusion (this morning while running) that the probability of this event can be anything between 0 and 1, rather than the three traditional 1/4, 1/3 and 1/2. Indeed, for any distribution of the “random” straws, hence for any distribution on the chord length L, a random draw can be expressed as L=F⁻¹(U), where U is uniform. Therefore, this draw is also an acceptable transform of a uniform draw, just like Bertrand’s three solutions.
Filed under: Books, R, Statistics Tagged: Bertrand’s paradox, chord, E.T. Jaynes, height, probability theory, R, simulation, triangle

var vglnk = { key: '949efb41171ac6ec1bf7f206d57e90b8' };

(function(d, t) {
var s = d.createElement(t); s.type = 'text/javascript'; s.async = true;
var r = d.getElementsByTagName(t)[0]; r.parentNode.insertBefore(s, r);
}(document, 'script'));

Related
ShareTweet

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

Tags: Bertrand's paradox, Books, chord, E.T. Jaynes, height, probability theory, R, Simulation, statistics, triangle```