This is a multi-part message in MIME format.
--------------080208010105080406030107
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Thank you, Henrik,
You're right. There was a mistake in my formula, which you correctly
identified.
Your formulas are correct and verify experimentally. I've attached a
short C program that prooves it.
I wish to thank everyone participating in this discussion,
Cristian Saita
Henrik Eriksson wrote:
> Dear Cristian-Augustin,
>
> There seems to be a mistake in your formula
> P = (2*a^3 + 2*b^3 - 4*a^2 - 4*b^2 - 4*a*b + 3*a + 3*b + 2)
> / (2 -a - b) / 3
> for, as you point out, a=0, b=1 should give P=2/3. My own
> calculations indicate that your first two terms 2*a^3+2*b^3
> should be a^3+a^2*b+a*b^2+b^3 instead. Then the expression
> simplifies to P = 1 - ((1-a)^2 + (1-b)^2) / 3
>
> If a<length1<b and c<length2<d the expression is a bit more
> complicated, so we introduce the following notation:
> AC4 = (1-a-c)^4, if (1-a-c) is positive, otherwise AC4=0
> and BC4, AD4, BD4 analogously. The final formula is
>
> P = 1 - (AC4-BC4-AD4+BD4)/3((1-a)^2-(1-b)^2)((1-c)^2-(1-d)^2)
>
> The derivation is straight-forward. First compute the
> probability P(L,M) that two randomly placed intervals of fixed
> lengths L and M will intersect. This is easy:
> P(L,M) = 1 - (1-L-M)^2 /(1-L)(1-M), if (1-L-M) is positive,
> otherwise P(L,M)=1. Next compute the probability density f(L)
> of the length of a random interval, under the condition that
> this length lies between a and b. This is even easier:
> f(L) = 2(1-L)/((1-a)^2-(1-b)^2), if a<L<b, zero otherwise.
> The desired probability is the very simple integral
> P = int f(L)f(M) P(L,M) dL dM over 0<L<1, 0<M<1.
>
> /Henrik Eriksson, Stockholm
--------------080208010105080406030107
Content-Type: text/plain;
name="intertest.cc"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="intertest.cc"
#include <iostream.h>
#include <stdlib.h>
int main() {
// number of tests
int N = 1000000;
// length constraints for the first interval
double a = 0.2;
double b = 0.4;
// length constraints for the second interval
double c = 0.1;
double d = 0.3;
// first interval
double x1, x2;
// second interval
double x3, x4;
// number of positive results to the intersection test
int count = 0;
for (int i = 0; i < N; i++) {
// generating the first interval
x1 = 1.0;
x2 = 0.0;
while (!(a <= x2 - x1 && x2 - x1 <= b)) {
x1 = double(random())/RAND_MAX;
x2 = double(random())/RAND_MAX;
}
// generating the second interval
x3 = 1.0;
x4 = 0.0;
while (!(c <= x4 - x3 && x4 - x3 <= d)) {
x3 = double(random())/RAND_MAX;
x4 = double(random())/RAND_MAX;
}
// intersection test
if (x1 <= x4 && x3 <= x2) {
count++;
}
}
// display the intersection probability result
cout << "Intersection Probability" << endl;
cout << "========================" << endl;
double pexp = double(count) / N;
cout << "Experimentally: " << pexp << endl;
double ac4 = (1 - a - c >= 0) ? (1 - a - c) : 0;
ac4*=ac4; ac4*=ac4;
double bc4 = (1 - b - c >= 0) ? (1 - b - c) : 0;
bc4*=bc4; bc4*=bc4;
double ad4 = (1 - a - d >= 0) ? (1 - a - d) : 0;
ad4*=ad4; ad4*=ad4;
double bd4 = (1 - b - d >= 0) ? (1 - b - d) : 0;
bd4*=bd4; bd4*=bd4;
double pthe = 1 - (ac4 - bc4 - ad4 + bd4) / (((1-a)*(1-a) - (1-b)*(1-b)) *
((1-c)*(1-c) - (1-d)*(1-d))) / 3;
cout << "Theoretically : " << pthe << endl;
return 0;
}
--------------080208010105080406030107--
.
.
=================================================================
Instructions for joining and leaving this list, remarks about the
problem of INAPPROPRIATE MESSAGES, and archives are available at:
. http://jse.stat.ncsu.edu/ .
=================================================================