
 bobbym
 Administrator
Probability question.
Hi;
This question appeared on another site:
3 sectors are drawn in the unit circle.One sector is 18° another is 36° and the last is 54°. What is the probability that all 3 sectors overlap with each other?
See figure 1 for a pictorial representation of the problem.
The exact probability is 11 / 400 but let us see what geogebra and mathematica can manage if we do not know that.
1)Draw 2 circles 1 at the origin with a radius of 1 and another at (1.5,0) with a readius of .15 using the Circle with Center and Radius tool.
2) For the smaller circle color it red with an opacity of 100% and hide the center point. Hide the xy axes.
3) Create a slider that uses integers from 1 to 2000 and put it in the right hand corner.
4) Create 3 random numbers:
r1 = n / n RandomUniform[0, 359] r2 = n / n RandomUniform[0, 359] r3 = n / n RandomUniform[0, 359]
the purpose of the weird notation will be explained later.
5) Create points (cos(r1°), sin(r1°)) and (cos((r1 + 18)°), sin((r1 + 18)°)). Point C and D will appear on the circle with an 18 degree angle between them.
6) Draw polygon ACD, color it red with an opacity of 50%. Find the midpoint of CD with the midpoint tool. Hide C and D you should only have the red sector and the point E. Hit the F9 key a few times to see the random 18 degree sector being drawn.
7) Create points (cos(r2°), sin(r2°)) and (cos((r2 + 36)°), sin((r2 + 36)°)). Point F and G will appear on the circle with an 36 degree angle between them.
8) Draw polygon AFG, color it green with an opacity of 50%. Find the midpoint of FG with the midpoint tool. Hide F and G you should only have the green and red sector and the point E and H.
9) Create points (cos(r3°), sin(r3°)) and (cos((r3 + 54)°), sin((r3 + 54)°)). Point F and G will appear on the circle with an 54 degree angle between them.
10) Draw polygon AJI, color it blue with an opacity of 50%. Find the midpoint of JI with the midpoint tool. Hide J and I you should only have the green, red and blue sector and the point E , H and K.
If you press F9 now you will see 3 random sectors created, we just now need to determine when there is a triple intersection and to count them.
11) Create a counter variable by entering counter = 0.
12) Create an input box using the insert input box tool and give it a Caption of reset and link it with counter. Give it an input length of 5 characters. Whatever you enter into its box will be assigned to the variable called counter. We will use it to zero it.
13) Get the object properties of the small red circle and in the advanced tab type this without quotes into the Condition to Show Object box,"(Distance[E, H] ≤ 0.45399) ∧ (Distance[K, H] ≤ 0.69466) ∧ (Distance[E, K] ≤ 0.58779)."
14) In the Scripting tab enter "If[(Distance[E, H] ≤ 0.45399) ∧ (Distance[K, H] ≤ 0.69466) ∧ (Distance[E, K] ≤ 0.58779),SetValue[counter,counter+1]]" in the On Update box.
15) Create another counter by just entering counter / n in the input bar, rename it to percentage. You may notice that in addition to F9 generating 3 sectors, the slider n also does and that when there is a triple intersection the red circle comes on.
Okay we are ready, move the slider all the way to the left. Enter in the Reset box 0. Set the slider in properties to increasing once. Highlight the slider and hold down the right arrow key to run the simulation. Slow down when you get close to 2000 so you can stop right on it. I got 50, for a percentage of .025 which is pretty close for only a run of 2000. What did you get?
With Mathematica we can do a little bit better. With a run of 200000 I got .0272 which is quite good.
In mathematics, you don't understand things. You just get used to them. I have the result, but I do not yet know how to get it. All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
Re: Probability question.
Where can I see the analytic answer, if one exists?
Also, I must try this one. Looks cool.
The limit operator is just an excuse for doing something you know you can't. “It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman “Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
 bobbym
 Administrator
Re: Probability question.
I can post it, if you want it.
In mathematics, you don't understand things. You just get used to them. I have the result, but I do not yet know how to get it. All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
Re: Probability question.
Sure. I just thought it was already somewhere on the forum.
The limit operator is just an excuse for doing something you know you can't. “It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman “Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
 bobbym
 Administrator
Re: Probability question.
Hi;
Daniel C wrote:The probability two sectors with central angles α and β intersect is (α+β) / (2π).
This can easily be proven with a diagram. The second sector can be right to the left or right of the first, or anywhere in between. This results in an angle of α+β.
Now, to the problem. Fix the sector with central angle π/10, and call it A. Consider the sector with central angle 2π/10, and call it B. The third sector is C. The probability B intersects A is 3/20, by the fact above.
Now, let f be the function that models the intersection of A and B for each position. Since area is linearly dependent on angle, f first rises, stays constant, and then falls (draw it yourself; draw a circle, a sector, and see where the second sector can intersect the first). The graph looks like a hill.
Either way, the point is that the expected value for the area of the intersection is π/15. Now, by our fact above, the probability that C intersects our current intersection is 11/60. Once again, this is valid because area is linearly dependent on angle.
Our probability is, multiplying our two probabilities: 3/20⋅11/60=11/400
In mathematics, you don't understand things. You just get used to them. I have the result, but I do not yet know how to get it. All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
Re: Probability question.
Hello M:
Thanks for all the work. Why did you choose polar coordinates and not vectors or the Sector command for the sectors? Can you post the Mathematica code when you get a chance?
 bobbym
 Administrator
Re: Probability question.
Hi;
Polar was a last resort, after more than a week of fumbling with those vectors, I finally gave up. Anyways, they have the same problem the sector command does. It was difficult to tell when there was a triple intersection. In the end the polygon  polar idea with the distance between the midpoints that finally worked. The M code is on the way.
In mathematics, you don't understand things. You just get used to them. I have the result, but I do not yet know how to get it. All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
Re: Probability question.
Working with it a tiny bit you do not need the midpoint idea at all. There is an IntersectRegion command that might work better.
 bobbym
 Administrator
Re: Probability question.
Hi;
I discovered that too after I had posted the program. It does appear to be a substantial improvement.
Here is the code you requested:
As you can see there is much chance for improvement. It will run faster on your machines than mine too.
In mathematics, you don't understand things. You just get used to them. I have the result, but I do not yet know how to get it. All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
Re: Probability question.
The dist function can be improved. We can leave out the radical for faster execution. It might be compilable. I see why you stuck with the midpoint idea for both.
 bobbym
 Administrator
Re: Probability question.
Hi;
Yes, it was the only way that could work in both programs. M does not have an IntersectRegion command.
In mathematics, you don't understand things. You just get used to them. I have the result, but I do not yet know how to get it. All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
Re: Probability question.
This could be solved by using the built in functions that Mathematica supplies.
 bobbym
 Administrator
Re: Probability question.
Hi;
I have been playing with that all night. So far, I have not done it. Perhaps you will?
In mathematics, you don't understand things. You just get used to them. I have the result, but I do not yet know how to get it. All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
 gAr
 Star Member
Re: Probability question.
Hi bobbym,
This can also be done without calculating the midpoints. We can consider the sample angle itself as the angle of the midpoint, and then calculate the distance.
The threshold of the distances are sqrt(2*(1cos 27)), sqrt(2*(1cos 36)) and sqrt(2*(1cos 45))
J simulation:
≈0.027433
Time taken for execution is about 0.758 seconds.
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense"  Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
 bobbym
 Administrator
Re: Probability question.
Hi gAr;
She came to the same conclusion. Very good work!
In mathematics, you don't understand things. You just get used to them. I have the result, but I do not yet know how to get it. All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
 gAr
 Star Member
Re: Probability question.
Hi bobbym,
Thanks for the idea
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense"  Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
