Consider two randomly chosen vectors (a,b) and (c,d) within the unit square, where a,b,c, and d are chosen uniformly from [0,1]. What is the expected angle between the vectors?

traucaderx7

traucaderx7

Open question

2022-08-14

Average angle between two randomly chosen vectors in a unit square
Consider two randomly chosen vectors (a,b) and (c,d) within the unit square, where a,b,c, and d are chosen uniformly from [0,1]. What is the expected angle between the vectors?

Answer & Explanation

Siena Bennett

Siena Bennett

Beginner2022-08-15Added 17 answers

Step 1
We have d x d y = r d r d ϕ. Denote the polar coordinates of the two points by r 1 , ϕ 1 and r 2 , ϕ 2 . We need two separate cases according as the points are in the same or different octants.
For the same octant, the integral over the region ϕ 2 < ϕ 1 < π 4 is
0 π 4 d ϕ 1 0 ϕ 1 d ϕ 2 0 1 cos ϕ 1 r 1 d r 1 0 1 cos ϕ 2 r 2 d r 2 ( ϕ 1 ϕ 2 ) = 1 4 0 π 4 d ϕ 1 1 cos 2 ϕ 1 0 ϕ 1 d ϕ 2 ϕ 1 ϕ 2 cos 2 ϕ 2 = 1 4 0 π 4 d ϕ 1 1 cos 2 ϕ 1 [ ( ϕ 1 ϕ 2 ) tan ϕ 2 log cos ϕ 2 ] 0 ϕ 1 = 1 4 0 π 4 d ϕ 1 log cos ϕ 1 cos 2 ϕ 1 = 1 4 [ tan ϕ 1 ( 1 + log cos ϕ 1 ) ϕ 1 ] 0 π 4 = π 16 + 1 8 log 2 1 4 .
Step 2
For different octants, the integral over the region ϕ 2 < π 4 < ϕ 1 is
π 4 π 2 d ϕ 1 0 π 4 d ϕ 2 0 1 cos ( π 2 ϕ 1 ) r 1 d r 1 0 1 cos ϕ 2 r 2 d r 2 ( ϕ 1 ϕ 2 ) = 1 4 π 4 π 2 d ϕ 1 1 cos 2 ( π 2 ϕ 1 ) 0 π 4 d ϕ 2 ϕ 1 ϕ 2 cos 2 ϕ 2 = 1 4 π 4 π 2 d ϕ 1 1 cos 2 ( π 2 ϕ 1 ) [ ( ϕ 1 ϕ 2 ) tan ϕ 2 log cos ϕ 2 ] 0 π 4 = 1 4 π 4 π 2 d ϕ 1 ϕ 1 π 4 + 1 2 log 2 cos 2 ( π 2 ϕ 1 ) = 1 4 0 π 4 d ϕ π 4 + 1 2 log 2 ϕ cos 2 ϕ = 1 4 [ ( π 4 + 1 2 log 2 ) tan ϕ ( ϕ tan ϕ + log cos ϕ ) ] 0 π 4 = 1 4 log 2 .
There are 4 symmetric copies of the first region and 2 of the second, for a total of π 4 + log 2 1 0.4785 .
This is not too different from the value π 6 0.5236 if the points are picked from the first quadrant of the unit disk.
Ashlynn Hale

Ashlynn Hale

Beginner2022-08-16Added 4 answers

Step 1
For this sort of problem, the first thing to do is minimize the numbers of variable you need to work with as much as possible. In this case, you can work with the angles of the two vectors directly.
Let
- θ 1 = tan 1 b a and θ 2 = tan 1 d c
- θ m = min ( θ 1 , θ 1 ) and θ M = max ( θ 1 , θ 2 )
- f ( θ ) be the common CDF for θ 1 , θ 2 , i.e.
f ( θ ) = CDF θ k ( θ ) = d e f P [ θ k θ ]  for  k = 1 , 2
The average angle you want is the expected value of | θ 1 θ 2 | = θ M θ m ,
To compute this, we need the CDF for θ m and θ M
CDF θ m ( θ ) = d e f P [ θ m θ ] = P [ θ 1 θ θ 2 θ ] = 1 P [ θ 1 > θ θ 2 > θ ] = 1 P [ θ 1 > θ ] P [ θ 2 > θ ] = 1 ( 1 f ( θ ) ) 2 CDF θ M ( θ ) = d e f P [ θ M θ ] = P [ θ 1 θ θ 2 θ ] = P [ θ 1 θ ] P [ θ 2 θ ] = f ( θ ) 2
Step 2
This allows us to express the average angle as an integral
A = d e f E [ | θ 1 θ 2 | ] = E [ θ M θ m ] = 0 π 2 θ ( CDF θ M CDF θ m ) d θ = 0 π 2 θ [ f 2 ( θ ) 1 + ( f ( θ ) 1 ) 2 ] d θ = 2 0 π 2 θ [ f ( θ ) ( f ( θ ) 1 ) ] d θ
Integrate by part and notice f ( θ ) + f ( π 2 θ ) = 1, we find
A = 2 0 π / 2 f ( θ ) ( 1 f ( θ ) ) d θ = 4 0 π / 4 f ( θ ) ( 1 f ( θ ) ) d θ
It is easy to see f ( θ ) = 1 2 tan θ for θ [ 0 , π 4 ]. Change variable to t = tan θ and integrate, the end result is:
A = 0 1 t ( 2 t ) 1 + t 2 d t = π 4 + log ( 2 ) 1

Do you have a similar question?

Recalculate according to your conditions!

New Questions in High school geometry

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?