Simulating a homogeneous Poisson point process on a rectangle

This is the first of a series of posts about simulating Poisson point processes. I’ll start with arguably the simplest Poisson point process on two-dimensional space, which is the homogeneous one defined on a rectangle. Let’s say that we we want to simulate a Poisson point process with intensity \(\lambda>0\) on a (bounded) rectangular region, for example, the rectangle \([0,w]\times[0,h]\) with dimensions \(w>0\) and \(h>0\) and area \(A=wh\). We assume for now that the bottom left corner of the rectangle is at the origin.


Number of points

The number of points in the rectangle  \([0,w]\times[0,h]\) is a Poisson random variable with mean \(\lambda A\). In other words, this random variable is distributed according to the Poisson distribution with parameter \(\lambda A\), and not just \(\lambda\), because the number of points depends on the size of the simulation region.

This is the most complicated part of the simulation procedure. As long as your preferred programming language can produce (pseudo-)random numbers according to a Poisson distribution, you can simulate a homogeneous Poisson point process. There’s a couple of different ways used to simulate Poisson random variables, but we will skip the details. In MATLAB, it is done by using the poissrnd function with the argument \(\lambda A\). In R, it is done similarly with the standard  function rpois . In Python, we can use either the scipy.stats.poisson or numpy.random.poisson function from the SciPy or NumPy libraries.

Location of points

The points now need to be positioned randomly, which is done by using Cartesian coordinates. For a homogeneous Poisson point process, the \(x\) and \(y\) coordinates of each point are independent uniform points, which is also the case for the binomial point process, covered in a previous post. For the rectangle \([0,w]\times[0,h]\), the \(x\) coordinates are uniformly sampled on the interval \([0,w]\), and similarly for the \(y\) coordinates. If the bottom left corner of rectangle is located at the point \((x_0,y_0)\), then we just have to shift the random \(x\) and \(y\) coordinates by respectively adding \(x_0\) and \(y_0\).

Every scientific programming language has a random uniform number generator because it is the default random number generator. In MATLAB, R and SciPy, it is respectively rand, runif and scipy.stats.uniform.


Here is some code that I wrote for simulating a homogeneous Poisson point process on a rectangle. You will notice that in all the code samples the part that simulates the Poisson point process requires only three lines of code: one line for the number of points and two lines lines for the \(x\) and \(y\) coordinates  of the points.

%Simulation window parameters
xDelta=xMax-xMin;yDelta=yMax-yMin; %rectangle dimensions

%Point process parameters
lambda=100; %intensity (ie mean density) of the Poisson process

%Simulate Poisson point process
numbPoints=poissrnd(areaTotal*lambda);%Poisson number of points
xx=xDelta*(rand(numbPoints,1))+xMin;%x coordinates of Poisson points
yy=yDelta*(rand(numbPoints,1))+yMin;%y coordinates of Poisson points


Note: it is a bit tricky to write “<-” in the R code (as it automatically changes to the html equivalent in the HTML editor I am using), so I have usually used “=” instead of the usual “<-”.

#Simulation window parameters
xDelta=xMax-xMin;yDelta=yMax-yMin; #rectangle dimensions

#Point process parameters
lambda=100; #intensity (ie mean density) of the Poisson process

#Simulate Poisson point process
numbPoints=rpois(1,areaTotal*lambda);#Poisson number of points
xx=xDelta*runif(numbPoints)+xMin;#x coordinates of Poisson points
yy=yDelta*runif(numbPoints)+yMin;#y coordinates of Poisson points


Note: “lambda” is a reserved word in Python (and other languages), so I have used “lambda0” instead.

import numpy as np
import scipy.stats
import matplotlib.pyplot as plt

#Simulation window parameters
xDelta=xMax-xMin;yDelta=yMax-yMin; #rectangle dimensions

#Point process parameters
lambda0=100; #intensity (ie mean density) of the Poisson process

#Simulate Poisson point process
numbPoints = scipy.stats.poisson( lambda0*areaTotal ).rvs()#Poisson number of points
xx = xDelta*scipy.stats.uniform.rvs(0,1,((numbPoints,1)))+xMin#x coordinates of Poisson points
yy = yDelta*scipy.stats.uniform.rvs(0,1,((numbPoints,1)))+yMin#y coordinates of Poisson points
plt.scatter(xx,yy, edgecolor='b', facecolor='none', alpha=0.5 )
plt.xlabel("x"); plt.ylabel("y")

After writing this post, I later wrote the code in Julia. The code is here and my thoughts about Julia are here.








Higher dimensions

If you want to simulate a Poisson point process in a three-dimensional box (typically called a cuboid or rectangular prism), you just need two modifications.

For a box \([0,w]\times[0,h]\times[0,\ell]\), the number of points now a Poisson random variable with mean \(\lambda V\), where \(V= wh\ell\) is the volume of the box. (For higher dimensions, you need to use $n$-dimensional volume.)

To position the points in the box, you just need an additional uniform variable for the extra coordinate. In other words, the \(x\), \(y\) and \(z\) coordinates are uniformly and independently sampled on the respective intervals \([0,w]\), \([0,h]\), \([0,\ell]\). The more dimensions, the more uniform random variables.

And that’s it.

Further reading

For simulation of point processes, see, for example, the books Statistical Inference and Simulation for Spatial Point Processes by Møller and Waagepetersen, or Stochastic Geometry and its Applications by Chiu, Stoyan, Kendall and Mecke.

There are books written by spatial statistics experts such as Stochastic Simulation by Ripley and Spatial Point Patterns: Methodology and Applications with R by Baddeley, Rubak and Turner, where the second book covers the spatial statistics R-package spatstat. Kroese and Botev also have a good introduction in the edited collection Stochastic Geometry, Spatial Statistics and Random Fields : Models and Algorithms by Schmidt, where the relevant chapter (number 12) is also freely available online.

More general stochastic simulation books that cover relevant material include Uniform Random Variate Generation by Devroye and Stochastic Simulation: Algorithms and Analysis by Asmussen and Glynn.

(Visited 9,775 times, 1 visits today)

Author: Paul Keeler

I am a researcher with interests in mathematical models involving randomness, particularly models with some element of geometry. Much of my work studies wireless networks with a focus on using tools from probability theory such as point processes. I come from Australia, where I call Melbourne home, but I have lived several years in Europe. I grew up in country Queensland and New South Wales.

11 thoughts on “Simulating a homogeneous Poisson point process on a rectangle”

  1. Thanks for the great post. I found a mistake in generating yy. It is yDelta instead of xDelta

  2. Thank you. It’s help me to do my homework . But I don’t understand number 1 in
    Please give me some information about that

    1. The R function rpois simulates random variables (more precisely, it generates random variates) according to a Poisson distribution. Read more here:

      The first function argument (in this case, 1) is the number of random variables. This mean it is only producing one random variable. If you want, say, 20 random variables, you change that number to 20.

      The second function argument is the Poisson parameter, meaning its mean. In this case, it is areaTotal*lambda, which is the total mass of the simulation window, as areaTotal is the total area and lambda is the density of the Poisson point process.

  3. Hi,

    Thanks for your post.

    Your code produces uniformly distributed points where the total number of points would be Poisson distributed if I would generate many realizations of these uniformly random point clouds.

    How is that a Poisson Point Process?

    Your clouds do not fulfill the definition, that the number of points in a region (i.e. any subset of your domain) of finite size is a random variable with a Poisson distribution (taken from wikipedia).

    An explanation would be highly appreciated.

    1. Thanks for your comment, Mark.

      Running one simulation doesn’t give you much. But with every simulation, the results will be a single realization (or outcome) of a homogeneous Poisson point process.

      The number of points is the variable numbPoints, which will vary (pseudo-randomly) over simulations. And that, in addition to the uniformly placed points, makes it a homogeneous Poisson point process.

      But you touch on an important point. If the number of points is a fixed (that is, constant) number, then yes, it will be a uniform point process, which is called a binomial point process, because the number of points in a certain region will be a binomial variable. For example, see the history section here:

      Unfortunately, the Wikipedia article is unnecessarily technical:

      Also see my previous post:

      This is all related to the fact if you take a Poisson point process, and condition on the number of points being some fixed number, it will be a binomial point process.

      But if you only do one simulation, it is impossible to a distinguish a binomial point process from a Poisson point process if the number of points numbPoints happens to be the same as that of the binomial point process. I believe this is what you are saying.

      In other words, to generate a homogeneous Poisson point process requires generating a binomial point process with a Poisson random number of points, and to see that Poisson behaviour, you have to generate the point process many times.

      And if you run the code over many simulations, and then just look at one subregion (for example, [0,0.5]x [0,0.5]), you’ll find that the points in that subregion also behave like a Poisson point process. In fact, the points in the other subregion (that is, the complement) will also behave like a Poisson point process. (I use verbs like behave, as we’re talking about statistics of computer simulations and not an actual mathematical object.)

      Here’s a post with some simple Poisson checks:

      The simplest check is that the first and second moments of the number of points agree in the Poisson case.

      I hope this clarifies things. Let me know if you need more details.

      1. This discussion might help also:

        For a Poisson point process, when points are uniformly located (in a random manner), we typically say homogeneous Poisson point process. The word homogeneous is often dropped. The points don’t have to be uniform, which then gives you a inhomogeneous or nonhomogeneous Poisson point process.

        Also I suggest the lectures notes by Baddeley, which form Chapter 1 of some published lectures (Springer Verlag), edited by Baddeley, Bárány, Schneider, and Weil. The binomial point process is covered in Section 1.3. You can find a link to the lectures on my post on the binomial point process.

Leave a Reply

Your email address will not be published. Required fields are marked *