Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Broken Stick Probability Please Help.

stick

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1 monkeyman

monkeyman

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 29 February 2016 - 09:01 AM

The basic problem: If a stick is broken randomly into three pieces, what is the probability that the three pieces can be arranged end-to-end to form a triangle?

 

My issue is I need to write a program to solve the above in Just Basic.... I don't know anything about Just Basic.... I have looked at the Just Basic forums and googled tutorials with no luck... not even sure if I am anywhere near right...

 

This is what I have so far but i keep getting errors and I don't know why.

 

length = 1
 
For i = 1 To n_iter
    x = Rnd()
    y1 = Rnd()
    y = y1 * (length - x)
    z = length - (x + y)
 
    If (is_triangle(x, y, z)) Then
        n_favourable = n_favourable + 1
    End If
 
Next i
 
 
Function is_triangle(a As Double, b As Double, c As Double)
 
is_triangle = 0
 
If (a < b + c And b < a + c And c < a + B) Then
    is_triangle = 1
End If
 
End Function
 





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download