# Geometric probability question

**URL:** <https://boards.straightdope.com/t/geometric-probability-question/325325>\
**Category:** Factual Questions\
**Created:** [October 8, 2005, 5:49pm UTC](https://boards.straightdope.com/t/geometric-probability-question/325325 "2005-10-08T17:49:42Z")\
**Posts on this page:** 8\
**Page:** 3

<div class="post-metadata">

**Author:** ![Punoqllads](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@Punoqllads](https://boards.straightdope.com/u/Punoqllads)\
**Post date:** [October 12, 2005, 6:07pm UTC](https://boards.straightdope.com/t/geometric-probability-question/325325/41 "2005-10-12T18:07:28Z")

</div>

The concavity test on the web page looks fine. All I can see that would make things fail is if there were some issue with how your random points were being generated or if there were some flaw in the counting code that was not transcribed to the web page code.

---

<div class="post-metadata">

**Author:** ![Omphaloskeptic](https://avatars.discourse-cdn.com/v4/letter/o/bcef8e/32.png) [@Omphaloskeptic](https://boards.straightdope.com/u/Omphaloskeptic)\
**Post date:** [October 12, 2005, 6:33pm UTC](https://boards.straightdope.com/t/geometric-probability-question/325325/42 "2005-10-12T18:33:06Z")

</div>

> [@ntucker](#):
>
> Still bugging me. There must be something wrong with my concavity test, but I don’t see it. I even wrote a little quick-and-dirty interactive drag-points-around-thingy to test it (warning, probably only works in IE: [http://www.area.com/ntucker/test/concquad.html](http://www.area.com/ntucker/test/concquad.html)) and all seems ok.
> 
> (there’s another at [http://www.area.com/ntucker/test/conc.html](http://www.area.com/ntucker/test/conc.html) which allows you to specify how many points, but it doesn’t test all permutations of point ordering, so you have to keep the points in order)

The code you posted looks correct; I ran a Perl script with that convexity check and got the right result (231704/1000000 ~ 25/108). How about the rest of the code? What’s the range of your RNG? Any chance of the cross product overflowing an int? (Does it work if you change the x and y coordinates to doubles?)

---

<div class="post-metadata">

**Author:** ![Punoqllads](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@Punoqllads](https://boards.straightdope.com/u/Punoqllads)\
**Post date:** [October 12, 2005, 7:16pm UTC](https://boards.straightdope.com/t/geometric-probability-question/325325/43 "2005-10-12T19:16:29Z")

</div>

The right result should be 25/36, not 25/108.

---

<div class="post-metadata">

**Author:** ![Omphaloskeptic](https://avatars.discourse-cdn.com/v4/letter/o/bcef8e/32.png) [@Omphaloskeptic](https://boards.straightdope.com/u/Omphaloskeptic)\
**Post date:** [October 12, 2005, 7:57pm UTC](https://boards.straightdope.com/t/geometric-probability-question/325325/44 "2005-10-12T19:57:28Z")

</div>

> [@Punoqllads](#):
>
> The right result should be 25/36, not 25/108.

Yes, but I ran **ntucker** ’s posted algorithm without permuting the order of the points. Only 1/3 of the time is the chosen ordering a correct order (as discussed above), so the “correct” result is 25/36/3=25/108. **ntucker** seems to be getting 1/6, for unknown reasons.

---

<div class="post-metadata">

**Author:** ![spinky](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@spinky](https://boards.straightdope.com/u/spinky)\
**Post date:** [October 13, 2005, 6:05am UTC](https://boards.straightdope.com/t/geometric-probability-question/325325/45 "2005-10-13T06:05:51Z")

</div>

> [@Omphaloskeptic](#):
>
> What’s the range of your RNG?

Big duh. My random range was **way** too high and the cross product calculation was overflowing very frequently. The odd part was how that resulted in such a round number for success rate (50%).

Results with new random number generator:  
convex = 69449805 out of 100000000 (69.4498%)

---

<div class="post-metadata">

**Author:** ![cerberus](https://avatars.discourse-cdn.com/v4/letter/c/71e660/32.png) [@cerberus](https://boards.straightdope.com/u/cerberus)\
**Post date:** [October 13, 2005, 7:27am UTC](https://boards.straightdope.com/t/geometric-probability-question/325325/46 "2005-10-13T07:27:24Z")

</div>

As stated, this query has a serious problem: 0- and 1-dimensional subsets of a 2-dimensional plane have zero probability mass under conventional probability measures, in particular when “at random” means the uniform distribution.

Now, replace that “plane” with a discrete set of points, and you’re in business…

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [October 13, 2005, 1:57pm UTC](https://boards.straightdope.com/t/geometric-probability-question/325325/47 "2005-10-13T13:57:09Z")

</div>

> [@cerberus](#):
>
> As stated, this query has a serious problem: 0- and 1-dimensional subsets of a 2-dimensional plane have zero probability mass under conventional probability measures, in particular when “at random” means the uniform distribution.
> 
> Now, replace that “plane” with a discrete set of points, and you’re in business…

I don’t see that as a problem. You’re picking four points from a plane, and considering the segments formed by them.

---

<div class="post-metadata">

**Author:** ![Topologist](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/topologist/32/3208_2.png) [@Topologist](https://boards.straightdope.com/u/Topologist)\
**Post date:** [October 13, 2005, 5:47pm UTC](https://boards.straightdope.com/t/geometric-probability-question/325325/48 "2005-10-13T17:47:00Z")

</div>

Or, to make clearer that we’re not asking about the probability of any 0- or 1-dimensional region: The sample space is 8-dimensional (the collection of lists of 4 points chosen from our plane figure) and the probability distribution is uniform. Within this 8-dimensional space is an 8-dimensional region consisting of those lists of points forming the corners of a convex quadrilateral. It’s the measure of that region that’s being calculated.

[Previous page](https://boards.straightdope.com/t/geometric-probability-question/325325.md?page=2)
