All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Shapes
Hexagon Picking Probability (Posted on 2023-10-25) Difficulty: 3 of 5
You choose a random point, uniformly, within a regular hexagon, with unit side length.

What's the average distance to the six sides?

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Computer solution | Comment 1 of 7
Program output:  1.1077388342288856

This could be calculated by taking the double integral
as x goes from 0 to 1/2, y goes from 0 to √3x of the distance formula
plus the double integral
as x goes from 1/2 to 1, y goes from 0 to √3(1-x) of the distance formula

The program below does the equivalent of numeric integration of the above.
wlog, the points are limited to the first equilateral triangle in the first quadrant, 
which has vertices (0,0), (1,0), (.5,√3/2).
Every point from (0,0) to (1,1) is considered but those outside this triangle are ignored.

--------------
s = 3**.5
t = (3**.5)/2
vertices = [[1,0],[.5,t],[-.5,t],[-1,0],[-.5,-t],[.5,-t]]

mesh = 1000
grid = [(i+.5)/(mesh)  for i in range(mesh)]


distances = []
for x in grid:
    for y in grid:
        if y > s*x:
            continue
        if y > s*(1-x):
            continue
        ddist = 0
        for v in vertices:
            ddist += ((v[0]-x)**2 + (v[1]-y)**2)**.5
        distances.append(ddist/6)

print(sum(distances)/len(distances))


  Posted by Larry on 2023-10-25 13:00:12
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (5)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (13)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information