pointpats.PoissonPointProcess

class pointpats.PoissonPointProcess(window, n, samples, conditioning=False, asPP=False)[source]

Poisson point process including \(N\)-conditioned CSR process and \(\lambda\)-conditioned CSR process.

Parameters
windowWindow

Bounding geometric object to contain point process realizations.

nint

Size of each realization.

sampleslist

Number of realizations.

conditioningbool

If True, use the \(\lambda\)-conditioned CSR process, number of events would vary across realizations; if False, use the \(N\)-conditioned CSR process.

asPPbool

Control the data type of value in the “realizations” dictionary. If True, the data type is point pattern as defined in pointpattern.py; if False, the data type is an two-dimensional array.

Examples

>>> import libpysal as ps
>>> import numpy as np
>>> from pointpats import Window
>>> from libpysal.cg import shapely_ext

Open the virginia polygon shapefile

>>> va = ps.io.open(ps.examples.get_path("virginia.shp"))

Create the exterior polygons for VA from the union of the county shapes

>>> polys = [shp for shp in va]
>>> state = shapely_ext.cascaded_union(polys)

Create window from virginia state boundary

>>> window = Window(state.parts)

1. Simulate a \(N\)-conditioned csr process in the same window (10 points, 2 realizations)

>>> np.random.seed(5)
>>> samples1 = PoissonPointProcess(window, 10, 2, conditioning=False, asPP=False)
>>> samples1.realizations[0] # the first realized event points
array([[-81.80326547,  36.77687577],
       [-78.5166233 ,  37.34055832],
       [-77.21660795,  37.7491503 ],
       [-79.30361037,  37.40467853],
       [-78.61625258,  36.61234487],
       [-81.43369537,  37.13784646],
       [-80.91302108,  36.60834063],
       [-76.90806444,  37.95525903],
       [-76.33475868,  36.62635347],
       [-79.71621808,  37.27396618]])

2. Simulate a \(\lambda\)-conditioned csr process in the same window (10 points, 2 realizations)

>>> np.random.seed(5)
>>> samples2 = PoissonPointProcess(window, 10, 2, conditioning=True, asPP=True)
>>> samples2.realizations[0].n # the size of first realized point pattern
10
>>> samples2.realizations[1].n # the size of second realized point pattern
13
Attributes
realizationsdictionary

The key is the index of each realization, and the value is simulated event points for each realization. The data type of the value is controlled by the parameter “asPP”.

parametersdictionary

Dictionary of a dictionary. The key is the index of each realization, and the value is a dictionary with the key ‘n’ and the value: 1. always equal to the parameter n in the case of N-conditioned process. For example, {0:{‘n’:100},1:{‘n’:100},2:{‘n’:100}} 2. randomly generated from a Possion process in the case of lambda-conditioned process. For example, {0:{‘n’:97},1:{‘n’:100},2:{‘n’:98}}

Methods

draw(self, parameter)

Generate a series of point coordinates within the given window.

realize(self, n)

Generate n points which are randomly and independently distributed in the minimum bounding box of “window”.

setup(self)

Generate the number of events for each realization.

__init__(self, window, n, samples, conditioning=False, asPP=False)[source]

Initialize self. See help(type(self)) for accurate signature.