1 0 0 × 1 0 0 grid. Suppose four points are randomly chosen on the grid. What is the probability that the convex hull of these four points is a quadrilateral?
Consider aGive your answer to 3 decimal places.
For reference on Monte-Carlo, here is an excellent wiki.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Determining whether or not 4 points chosen at random makes for a convex quadrilateral is always a problematic one, but here's a different way to do it:
1) Taking groups of 3 points out of 4 , we determine the areas formed by the 4 triangles, and find the largest area
2) Taking the 3 different cyclic orders of 4 points, we determine the 3 quadrilateral areas formed by the 4 points, and find the largest area
3) If the largest area in 2) is > than the largest area in 1), then count it as a convex quadrilateral
4) Repeat 1 0 0 M times for a good Monte Carlo run with at least 3 decimal digits accuracy
Note: Use the shoelace formula for finding areas
Parallel C++ code doing a suitable simulation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
Compute the average area of a triangle when any three of the points are i.i.d. chosen from a square. The fourth point must lie within the boundary of this triangle to not be part of the convex hull. This point can be chosen in four ways. The complement of this probability is the solution.
This is the solution in MATLAB.
1 2 3 4 5 6 7 8 |
|
Relevant wiki: Monte-Carlo Simulation
I always liked Monte-Carlo simulation. Everything is so mysterious until you run it and see how the probability converges.
For this problem, if the convex hull formed by the 4 points are not a quadrilateral, this implies that one of the points must be within the triangle formed by the remaining three points. Fortunately there are only 4 points and thus we don't have to code the convex hull algorithm. Instead, we can check if one point is within the triangle. To do that, we first compute the areas of the 4 possible triangles (with the shoelace formula ) and see if any one of them is the sum of the remaining three. If this holds, the convex hull is a triangle and is not a quadrilateral.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
With this code you can see how the probability converges to
0.6925
.
Graham's scan is one of several ways of computing the convex hull of a set of points in the plane. This codes uses a version due to Mr Tom Switzer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
Problem Loading...
Note Loading...
Set Loading...
Relevant wiki: Monte Carlo Simulation
For four points to satisfy the condition of the problem, every point must be outside the triangle formed by the others points.
This is a Monte Carlo solution written in python 3.4 :