[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

1292.0. "What is the Expented Value for the area of a triangle in a unit square?" by SEURAT::NEWMAN (Chuck Newman, 297-5499, MRO4-1/H16, Pole J13) Thu Sep 06 1990 16:40

I was able to come up with several ways of solving the problem:

Find the expected value for the distance between two random points on a unit
line segment.

        0---x--------y----1

The answer is one-third.

-----------------------------------------------
It took me much longer before I found a solution for the following problem:

Find the expected value for the area of the triangle formed by three random 
points on a unit square.


         --------------------
         |                  |
         |        C         |
         |       / \        |
         |      /   \       |
         |     /     \      |
         |    /       \     |
         |   A---------B    |
         |                  |
         |                  |
         |                  |
         --------------------					-- Chuck Newman
T.RTitleUserPersonal
Name
DateLines
1292.1GUESS::DERAMODan D'EramoFri Sep 07 1990 00:5342
>> Find the expected value for the distance between two random points on a unit
>> line segment.
>>
>>         0---x--------y----1
>>
>> The answer is one-third.

	This works out to be the double integral for x from 0 to 1,
	for y from 0 to 1, of |x-y|, dy dx, call it

		int(0,1) int(0,1) |x-y| dy dx

	Break up the inner integral into

		int(0,1) ( int(0,x) |x-y| dy + int(x,1) |x-y| dy ) dx

	which is

		int(0,1) ( int(0,x) x-y dy + int(x,1) y-x dy ) dx

	=
				       |x		|1
		int(0,1) ( xy-(1/2)y^2 |  + (1/2)y^2-xy |  ) dx
				       |0		|x

	=

		int(0,1) ( x^2-(1/2)x^2 + 1/2-x + -(1/2)x^2+x^2 ) dx

	=

		int(0,1) ( 1/2 - x + x^2 ) dx

	=
					     |1
		(1/2)x - (1/2)x^2 + (1/3)x^3 |  = 1/2 - 1/2 + 1/3
					     |0
	=

		1/3

	Dan
1292.2a possible approachALLVAX::JROTHIt's a bush recording...Fri Sep 07 1990 05:1553
<<< Note 1292.0 by SEURAT::NEWMAN "Chuck Newman, 297-5499, MRO4-1/H16, Pole J13" >>>
     -< What is the Expented Value for the area of a triangle in a unit  >-

    Well, I thought about this a little while out training on my bicycle.

    You could get this by integrating the absolute value of the determinant

	| x1 y1  1 |
	| x2 y2  1 | dx1 dy1 dx2 dy2 dx3 dy3
	| x3 y3  1 |

    over the unit cube.  The area has 12-fold symmetry by permutations of the
    rows and first 2 columns of the matrix, plus there are reflections in the
    various coordinates.

    Here is a possible way to simplify the integral.

    Consider first a simpler problem where one vertex of a triangle
    is at the origin, say P0 = (0,0), P1 = (x1,y1), and P2 = (x2,y2).

    Then the area is 1/2 x1*y2 - y1*x2.

    This is twice the difference between the areas of overlapping rectangles:

    +--------------------+
    |                    |
    |                    |
y2  +-------+-----+      |
    |       |     |      |
    |  +    |  0  |      |
y1  +-------+-----+      |
    |       |     |      |
    |  0    |  -  |      |
    +-------+-----+------+
	    x1    x2

    The signs of the areas will depend on the ordering of the values on the
    axes.

    In the same way we can get the area of a general triangle in the unit square
    by considering the overlapping areas of 6 rectangles formed by the
    expression

	x1*y2 - y1*x2 - x1*y2 + y1*x3 + x2*y3 - y2*x3

    There will be 6 permutations of ordered values on each axis, but one
    ordering can be chosen for, say, the x axis and the expected area can
    be integrated by considering the remaining permutations.

    I'll have to work thru the details, but this is the easiest approach
    I can think of.

    - Jim
1292.3Solution for random triangleALLVAX::JROTHIt's a bush recording...Sun Sep 09 1990 06:2150
    Here's an easy way to calculate the expected area of the triangle.

    The area is half the absolute value of the determinant

	| x1 y1  1 |
	| x2 y2  1 |
	| x3 y3  1 |

    Note that this is a linear form in the x's and y's, so it makes sense
    to first calculate the expected area conditional on a given set of x's
    and then integrate that to get the overall average.

    Without loss of generality, let x1 < x2 < x3 and set x12 = x2-x1,
    x13 = x3-x1 and x23 = x3-x2.  x12, x13, x23 are all nonnegative.

    Integrating

	| y1 x23 - y2 x13 + y3 x12 | dy2 dy1 dy3

    over the limits 0 < y1,y2,y3 < 1 we find the expression

	2 x23^2 + 3 x23 x12 + 2 x12^2
	-----------------------------
		   6 x13

   Integrate with respect to y2 (the middle vertex) first since this makes
   it easy to break the integral into two pieces to take account of the
   absolute value.  The area changes sign when y2 crosses the line joining
   vertices 1 and 3.

   This is the expected area given a set of x coordinates in sorted order.

   Finally integrate this over the limits

	0 < x1 < 1
	0 < x13 < 1-x1
	0 < x12 < x13

   and obtain 11/(9*48).  Integrate x12 first to allow cancelling the x13
   in the denominator.

   Taking account of the 6 fold symmetry under permutations of the ordered
   x coordinates and halving we get the expected area

	Aavg = 11/144 ~= .0763888888...

   With the same approach you could get the area of a random tetrahedron
   or n-simplex but I'll bet it's really messy :-(

   - Jim
1292.4GUESS::DERAMODan D'EramoSun Sep 09 1990 17:0010
	.2 didn't say that the area was the absolute value of the
	determinant, just that you could get the area if you had the
	absolute value of the determinant.  .3 makes explicit that the
	area is half of the absolute value of the determinant.  (I
	verified that symbolically, and it works.)

	I ran a million random trials using VAX LISP and the average
	area was 0.0764, which agrees with the value computed in .3.

	Dan
1292.5Yup -- that's the answer I gotHDLITE::NEWMANChuck Newman, 297-5499, MRO4-1/H16, Pole J13Mon Sep 10 1990 16:235
Boy that's easier than what I did -- brute forcing it by doing
limit-of-the-sums.  I got the same answer too, which agreed with the results
of a test program. 

							-- Chuck Newman 
1292.6GUESS::DERAMODan D'EramoMon Sep 10 1990 17:043
	Proof by consensus. :-)

	Dan
1292.7proof by oracle :-)ALLVAX::JROTHIt's a bush recording...Tue Sep 11 1990 13:5845
>>               <<< Note 1292.6 by GUESS::DERAMO "Dan D'Eramo" >>>

>>	Proof by consensus. :-)

>>	Dan

Vitus $ maple

    |\^/|
._|\|   |/|_. Licensed to Digital Equipment of Canada
 \  MAPLE  /  Version 4.3 --- Mar 1989
 <____ ____>  For on-line help, type  help();
      |

> a := array(1..3,1..3,[[1,x1,y1],[1,x2,y2],[1,x3,y3]]);
                                    [ 1  x1  y1 ]
                                    [           ]
                               a := [ 1  x2  y2 ]
                                    [           ]
                                    [ 1  x3  y3 ]

> with(linalg,det);
                                     [det]

> abar := 6*int(int(int(int(int(int(det(a),
>       y2=0..solve(det(a),y2)),y1=0..1),y3=0..1),
>       x2=x1..x3),x1=0..x3),x3=0..1);

bytes used=413480, alloc=180224, time=5.660
bytes used=816816, alloc=368640, time=12.140
bytes used=1007544, alloc=458752, time=17.040

                                           11
                                  abar := ---
                                          144

> evalf(abar);
                                  .07638888889

> quit;

bytes used=1117156, alloc=458752, time=19.270

Vitus $

1292.8GUESS::DERAMODan D'EramoTue Sep 11 1990 14:243
	(sigh) I want one of those.

	Dan