# Calculating expected number of points within polygons of different size under hypothesis of random distribution?

Let's imagine we have some polygons that cover a whole study plot (see attached picture). Further, we have some points (red dots) lying within the polygons. For each polygon we want to calculate the expected number of points, against which compare the observed number of points, and to calculate the significance (i.e., p-value) of the observed number of points under the Null Hypothesis of a random distribution of points within the study area as a whole.

We actually know (a) the area of each polygon, (b) the total area of the study plot (=sum of the polygons' area), (c) the total number of points, and (d) the number of points falling inside each polygon.

For the p-value, my best guess is to use the binomial distribution, but I can't figure out how to exactly do that. In particular, where I am stuck is in working out the value of p, which in the case of polygons of equal size (i.e., quadrats) should be the reciprocal of the number of quadrats into which the study area is divided. But I do not know how to calculate p in case of polygons of unequal size.

In case of quadrats (equal sized polygons), I have read that we should use a binomial distribution with:

p=1/x (where x is the number of quadrats)

n=number of events in the pattern (i.e., total number of points)

k=number of events in a quadrat.

In the specific case I described, would p be equal to the fraction of each polygon's area relative to the whole study plot (i.e., p=polygon area/sum of all the polygons area)? This is what the `spatstat` function `quadrat.test` does. If there are small numbers of points in the areas then this method doesn't work too well, so it does a Monte-carlo simulation approach. A number of simulations of complete spatial randomness are done and counts of observed-under-simulation are compared with observed-data using chi-squared statistics again. The estimate of the intensity of the simulated pattern comes from the number of points in the data.
That's all explained nicely in the help for `quadrat.test` in R and in most good spatial statistics books.