Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's because you used "random endpoints" chord selection (which has the probability of 1/3). Now try it with the "random radius" and "random midpoint" methods described here: https://en.wikipedia.org/wiki/Bertrand_paradox_%28probabilit...

It's probably not wise to assume that you just easily solved a 100+ year old unsolved mathematical problem.



I'm thinking though that if you talk a fairly large area surrounding a circle, and then randomly selected two points within it. Draw a line between the two points. If the line intersects the circle, calculate the length the length of it's chord. Bigger then sqrt(3) or less get put into bins, and the probability is calculated from there. Obviously this would work better if the area was an infinite plane, but I would expect to see the answer tending to a value as the size of the area increased.

I don't believe that this approach makes any assumptions about the chords that it generates. Here's a ruby snippet that does just that (err, I think!)

plane_size = 10000.0 chords = []

while chords.size < 100 p1 = {} p2 = {}

    p1[:x] = Random.rand(plane_size) - plane_size / 2
    p1[:y] = Random.rand(plane_size) - plane_size / 2
    p2[:x] = Random.rand(plane_size) - plane_size / 2
    p2[:y] = Random.rand(plane_size) - plane_size / 2
    puts p1
    puts p2
    #gradient 'm'
    m = (p2[:y] - p1[:y]) / (p2[:x] - p1[:x])
    #y = mx + b
    # => b = y - mx
    b = p2[:y] - m * p2[:x]

    #x^2 + y^2 = 1
    #sub in y from the line equation
    #x^2 + (mx + b) * (mx + b) = 1
    #x^2 + m^2x^2 + 2bmx + b^2 = 1
    #x^2(1 + m^2) + 2bmx + b^2 - 1 = 0

    #apply the quadratic equation to find the roots
    #Ax^2 + Bx + C = 0
    #=>x = (-B +- sqrt(b^2 - 4AC)) / 2A

    #in our case, A = (1 + m^2), B = 2bm, C = b^2 -1
    #the line intersects if B^2 -4AC > 0
    discriminator = (2 * b * m) * (2 * b * m) - 4 * (1 + m * m) * (b * b - 1) 
    if discriminator > 0 then
        chord1 = {}
        chord2 = {}
        chord1[:x] = (-2 * b * m + Math.sqrt(discriminator) ) / (2 * (1 + m * m))
        chord1[:y] = m * chord1[:x] + b
        chord2[:x] = (-2 * b * m - Math.sqrt(discriminator) ) / (2 * (1 + m * m))
        chord2[:y] = m * chord2[:x] + b
        length = Math.sqrt((chord2[:x] - chord1[:x]) * (chord2[:x] - chord1[:x]) + 
                        (chord2[:y] - chord1[:y]) * (chord2[:y] - chord1[:y]))
        chords << length
    end
 end

 smaller = 0
 chords.each {|c| smaller += 1 if c < Math.sqrt(3) }
 puts "The number of chords smaller than sqrt(3) = #{smaller/100.0}%"

If I believe the result, the real world seems to feel that the answer is 0.5

Edit: Hah! Should have read just a few comments further, and I would have seen some other posts doing exactly the same thing. Good to see we ended up with the same answer :D


Your answer will follow from the chosen "random" sampling method. Since the sampling method is not stated as part of the problem, there is ambiguity.

For this Ruby snippet, you chose random (x,y) coordinate pairs on a plane. This corresponds to selection method #2 as outlined on the Wikipedia article [0]. Scroll down a bit to see different selection methods visualized!

[0] https://en.wikipedia.org/wiki/Bertrand_paradox_%28probabilit...


Why do they say "unsolved" if the classical solution seems to deal with the "paradox"?


We have conjectures and approaches but no proven solution.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: