# Point process simulation

Point processes are mathematical objects that can represent a collection of randomly located points on some underlying space. There is a rich range of these random objects, and, depending on the type of points process, there are various steps and methods used to sample, simulate or generate them on computers. (I use these three terms somewhat interchangeably.) This is the first of a series of posts in which I will describe how to simulate some of the more tractable point processes defined on bounded regions of two-dimensional Euclidean space.

### Finite point processes

A general family of point processes are the finite point processes, which are, as the name suggests, simply point processes with the property that the total number of points is finite with probability one. Usually it is assumed that both the number of points and the positions of these points are random. These two properties give a natural way to describe and to study point processes mathematically, while also giving an intuitive way to simulate them on computers.

If the number and locations of points can be simulated sequentially, such that the number of points is naturally generated first followed by the placing of the points, then the simulation process is usually easier. Such a point process is a good place to start for an example.

### Simple example — Binomial point process

The binomial point process is arguably the simplest point process. It is created by scattering $$n$$ points uniformly and independently located in some bounded region, say, $$R$$ with area $$|R|$$. The number of points located in a region $$B\subset R$$ is a binomial random variable, say, $$N$$, where its probability parameter $$p=\frac{|B|}{|R|}$$ is simply the ratio of the  two areas. This implies that

$$P(N=k)={n\choose k} p^k(1-p)^{n-k},$$

The total number of points is non-random number $$n$$, so we do not need to generate it as it is given. The independence of point locations means that all the points can be positioned in parallel.

For example, to simulate $$n$$ points of a binomial point process on the unit square $$[0,1]\times[0,1]$$, we just need to independently sample the $$x$$ and $$y$$ coordinates of the points from a uniform distribution on the unit interval $$[0,1]$$. In other words, we randomly generate or sample two sets of $$n$$ uniform random variables corresponding to the $$x$$ and $$y$$ of the $$n$$ points.

To sample on a general $$w \times h$$ rectangle, we just need need to multiple the random $$x$$ and $$y$$ values by the respective dimensions of the rectangle $$w$$ and $$h$$. Of course the rectangle can also be shifted up or down by adding or subtracting $$x$$ and $$y$$ values appropriately.

Essentially every programming language has a function for generating uniform random numbers because it is the default random number generator, which all the other random number generators build off, by employing various techniques like applying transformations. In MATLAB, R and Python, it is respectively rand, runif and scipy.stats.uniform, which all generate uniform points on the open interval $$(0,1)$$.

### Code

Here are some pieces of code that illustrates how to simulate a binomial point process on the unit square. I suggest downloading the code directly here from my repository. (Sometimes my webpage editor mangles simulation code.)

MATLAB

n=10; %number of points

%Simulate binomial point process
xx=rand(n,1);%x coordinates of binomial points
yy=rand(n,1);%y coordinates of binomial points

%Plotting
scatter(xx,yy);
xlabel('x');ylabel('y');


R

n=10; #number of points
#Simulate Binomial point process
xx=runif(n);#x coordinates of binomial points
yy=runif(n);#y coordinates of binomial points

#Plotting
plot(xx,yy,'p',xlab='x',ylab='y',col='blue');


Python

import numpy as np
import matplotlib.pyplot as plt

numbPoints = 10; # number of points

# Simulate binomial point process
xx = np.random.uniform(0, 1, numbPoints) # x coordinates of binomial points
yy = np.random.uniform(0, 1, numbPoints) # y coordinates of binomial points

# Plotting
plt.scatter(xx, yy, edgecolor='b', facecolor='none', alpha=0.5)
plt.xlabel('x')
plt.ylabel('y')
plt.show()


### More complicated point processes

The binomial point process is very simple. One way to have a more complicated point process is to have a random number of points. The binomial point process is obtained from conditioning on the number of points of a homogeneous Poisson point process, implying its simulation builds directly off the binomial point process. The homogeneous Poisson point process is arguably the most used point process, and it is then in turned used to construct even more complicated points processes. This suggests that the homogeneous Poisson point process is the next point process we should try to simulate.