Given 5 points inside a square of side 10 cm, what is the probability that
at least two of the points are within 8cm of each other?
(In reply to
re: computer soln by Daniel)
Right you both are! 10*sqrt(2)/2<8 (do'h!)
There was a bug as you found. The output of the new code is below!
D'oh! (Trick problem, much like the rope between the poles.....)
exp?
7 64
cnt = 0
10000000 1.0000000000000 0.0000000000000
exp?
8 64
cnt = 0
100000000 1.0000000000000 0.0000000000000
program sq5
implicit none
integer good,seed,pa(2,10),i,j,exp,big,cnt
real*8 dd,x(5),y(5),dx2,dy2,d,prob,prob1,xbig
data pa/1,2,1,3,1,4,1,5,2,3,2,4,2,5,3,4,3,5,4,5/
seed=time8()
call srand(seed)
1 print*,'exp?'
read*,exp,dd
big=10**exp
xbig=big
if(exp.eq.0)stop
cnt=0
do i=1,big
do j=1,5
x(j)=10*rand()
y(j)=10*rand()
enddo
do j=1,10
dx2=(x(pa(1,j))-x(pa(2,j)))**2
dy2=(y(pa(1,j))-y(pa(2,j)))**2
d=dx2+dy2
c print*,i,d
if(d.lt.dd)go to 3
enddo
cnt=cnt+1
3 enddo
print*,'cnt = ',cnt
prob=(big-1.d0*cnt)/xbig
prob1=1.d0-prob
print4,big,prob,prob1
4 format(i9,2(1x,f15.13))
go to 1
end
Edited on August 5, 2019, 10:57 pm