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 a single focus of cancer d mm in diameter, that the probability distribution of its center is uniform and further assumes that the quarter discs shown in the diagram 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 = d/2 is its radius. In terms of the diamter this can be written as pi * d^2/4. 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.

To double check we can compare the above formula to a simulation. If the cancer has a diameter of d = 2mm and each side is s = 5mm, then the probability of detecting the cancer, is 0.50265 by the formula and 0.4955 via the simulation below -- these two numbers are equal to two decimal places. We review the formula calculation and then the simulation:

1. Formula. Using the formula above and substituting in d = 2 and s = 5 we find that the probability of detection is 0.50265 (and so the probability of missing the cancer is 1 - 0.50265 = 0.49737).

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

2. Simulation. Using the R code at the end we create a simulation again assuming d = 2 and s = 5. d as well as s and n (number of iterations) can all be changed as needed by modifying their values near the top of the code. The code generates n = 10,000 points uniformly in an s by s square and then counts the fraction lying within d/2 of a corner as the probability of detection. This approach is more general since it also works even in the case where the discs at the 4 corners of the square overlap. Run it by copying the code below to the clipboard and paste it into the text input box at http://www.r-fiddle.org -- be sure to erase anything already in the r-fiddle text entry box first. Then press Run. (You may need to press Run twice if the answer does not appear the first time.) The code below gives the probability of detection and 1 minus that number is the probability of missing the cancer.

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)

## No comments:

Post a Comment