One quarter of each of those discs lies in the particular square so the total area of those discs within that square divided by the area of the square is the probability of detection. (This assumes the probability distribution of the circle centers is uniform and assumes that the discs are not so large that they overlap.)

```
probability of detection of cancer
```

`= probability that the center of the cancer lies in one of the 4 quarter discs `

`= (sum of 1/4 of the area of 4 discs of diameter d) / (area of one grid square) `

`= 4 * 1/4 * (area of a disc of diameter d) / (area of one grid square) `

`= (area of a circle of diameter d) / (area of one grid square) `

`= (pi * (d^2)/4) / s^2`

` `

We used the fact that the area within a circle is pi*r^2 where r is its radius. This implies it equals pi * d^2/4 where d is its diameter. The above only works if the 4 quarter circles do not overlap and that is guaranteed if d is less than s. If d is greater than s then the quarter circles would overlap and adding their areas would represent double counting in the overlapping regions.

For a diameter of d = 2 mm we can compare the formula's result, 0.50265, with the result of a simulation, 0.4955, which generates 10,000 points uniformly on the square and counts the fraction of points lying within 2mm of a corner. To two decimal places both give 0.50 for d=2mm. Unlike the formula, the simulation is not restricted to the case where d is less than s. Both the formula and the simulation give the probability of detecting the 2mm cancer. The probability of missing the cancer is 1 minus the probability of detecting it.

1. Here is the calculation using the formula using d = 2 and s = 5:

`(pi * (d^2)/4) / s^2 = (3.1415926 * 4^2/4) / 5^2 = 0.50265`

2. Here is the the R code for the simulation again assuming d = 2 and s = 5. d as well as s and n (number of iterations) can be changed as needed. Run it by pasting the code into http://www.r-fiddle.org -- be sure to erase anything already in the r-fiddle text entry box first. You may need to press Run twice if the answer does not appear the first time. The answer that the R code simulation gives, 0.4955, equals the theoretical value of detection from the formula (0.5265) to two decimal places: The code below gives the probability of detection.

Thanks to Don Morris for raising this problem.set.seed(123) n <- 10000 # number of iterations in simulation s <- 5 # length of side of a grid square d <- 4 # diameter of each of the 4 discs centred at the 4 corners r <- d/2 x <- runif(n, 0, s) y <- runif(n, 0, s) mean(x^2 + y^2 < r^2 | (s - x)^2 + y^2 < r^2 | x^2 + (s-y)^2 < r^2 | (s-x)^2 + (s-y)^2 < r^2)