Generates completely spatially random points in a polygon (M.A. Mugglestone, S.A. Harding, B.Y.Y. Lee, P.J. Diggle & B.S. Rowlingson).
Option
PRINT = string token |
What to print (summary); default summ |
|---|
Parameters
YPOLYGON = variates |
Vertical coordinates of each polygon; no default – this parameter must be set |
|---|---|
XPOLYGON = variates |
Horizontal coordinates of each polygon; no default – this parameter must be set |
NPOINTS = scalars |
How many points to generate in each polygon; no default – this parameter must be set |
YCSR = variates |
Variates to receive the vertical coordinates of the points that have been generated |
XCSR = variates |
Variates to receive the horizontal coordinates of the points that have been generated |
SEED = scalars |
Seeds for the random numbers used to generate the points; default 0 |
Description
The term complete spatial randomness (CSR) is used to represent the hypothesis that the overall density of events in a spatial point pattern is constant throughout the study region, and that the events are distributed independently and uniformly (see Diggle 1983). This procedure generates a simulated realization of CSR in a given polygon. The coordinates of the polygon are specified using the parameters XPOLYGON and YPOLYGON. The number of points to be generated is specified using the parameter NPOINTS. The coordinates of the points which are generated may be saved using the parameters XCSR and YCSR. The SEED parameter allows a seed to be supplied for generating the random numbers used to generate the points (thereby producing reproducible results). If this is not supplied, the default of 0 initializes the random number generator (if necessary) from the system clock.
Print output is controlled using the PRINT option. The default setting of summary prints the horizontal and vertical coordinates of the points which are generated under the headings XCSR and YCSR.
Option: PRINT.
Parameters: YPOLYGON, XPOLYGON, NPOINTS, YCSR, XCSR, SEED.
Method
A procedure PTCHECKXY is called to check that XPOLYGON and YPOLYGON have identical restrictions. The parameters XPOLYGON, YPOLYGON and NPOINTS are then passed to a sub-procedure called GRCSR_GENPTS. The sub-procedure generates points randomly in the bounding box of the polygon specified by XPOLYGON and YPOLYGON using the URAND function. It then calls PTSINPOLYGON to exclude any points which lie outside the polygon. If the number of points retained is less than NPOINTS then GRCSR_GENPTS is called again recursively until at least NPOINTS points have been generated. Finally, the EQUATE directive is used to transfer the coordinates of the first NPOINTS points generated by GRCSR_GENPTS to the parameters XCSR and YCSR.
Action with RESTRICT
If XPOLYGON and YPOLYGON are restricted, only the subset of values specified by the restriction will be included in the calculations.
Reference
Diggle, P.J. (1983). Statistical Analysis of Spatial Point Patterns. Academic Press, London.
See also
Procedures: GRLABEL, GRTHIN, GRTORSHIFT.
Commands for: Calculations and manipulation, Spatial statistics.
Example
CAPTION 'GRCSR example'; STYLE=meta
VARIATE xhexagon; VALUES=!(0.3,0.0,0.3,0.7,1.0,0.7)
& yhexagon; VALUES=!(0.0,0.5,1.0,1.0,0.5,0.0)
GRCSR [PRINT=*] YPOLYGON=yhexagon; XPOLYGON=xhexagon; NPOINTS=50;\
YCSR=ycsr; XCSR=xcsr
DPTMAP [YLOWER=0; YUPPER=1; XLOWER=0; XUPPER=1] Y=ycsr; X=xcsr
DPOLYGON [SCREEN=keep] YPOLYGON=yhexagon; XPOLYGON=xhexagon; PEN=2