Geometric probability question

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.

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?)

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.

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%)

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.

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.