RipleysKEstimator

class astropy.stats.RipleysKEstimator(area, x_max=None, y_max=None, x_min=None, y_min=None)[source] [edit on github]

Bases: object

Estimators for Ripley’s K function for two-dimensional spatial data. See [1], [2], [3], [4], [5] for detailed mathematical and practical aspects of those estimators.

Parameters:
area : float

Area of study from which the points where observed.

x_max, y_max : float, float, optional

Maximum rectangular coordinates of the area of study. Required if mode == 'translation' or mode == ohser.

x_min, y_min : float, float, optional

Minimum rectangular coordinates of the area of study. Required if mode == 'variable-width' or mode == ohser.

References

[1](1, 2) Peebles, P.J.E. The large scale structure of the universe. <http://adsabs.harvard.edu/cgi-bin/nph-bib_query?bibcode=1980lssu.book…..P&db_key=AST>
[2](1, 2) Spatial descriptive statistics. <https://en.wikipedia.org/wiki/Spatial_descriptive_statistics>
[3](1, 2) Package spatstat. <https://cran.r-project.org/web/packages/spatstat/spatstat.pdf>
[4](1, 2) Cressie, N.A.C. (1991). Statistics for Spatial Data, Wiley, New York.
[5](1, 2) Stoyan, D., Stoyan, H. (1992). Fractals, Random Shapes and Point Fields, Akademie Verlag GmbH, Chichester.

Examples

>>> import numpy as np
>>> from matplotlib import pyplot as plt # doctest: +SKIP
>>> from astropy.stats import RipleysKEstimator
>>> z = np.random.uniform(low=5, high=10, size=(100, 2))
>>> Kest = RipleysKEstimator(area=25, x_max=10, y_max=10,
... x_min=5, y_min=5)
>>> r = np.linspace(0, 2.5, 100)
>>> plt.plot(r, Kest.poisson(r)) # doctest: +SKIP
>>> plt.plot(r, Kest(data=z, radii=r, mode='none')) # doctest: +SKIP
>>> plt.plot(r, Kest(data=z, radii=r, mode='translation')) # doctest: +SKIP
>>> plt.plot(r, Kest(data=z, radii=r, mode='ohser')) # doctest: +SKIP
>>> plt.plot(r, Kest(data=z, radii=r, mode='var-width')) # doctest: +SKIP
>>> plt.plot(r, Kest(data=z, radii=r, mode='ripley')) # doctest: +SKIP

Attributes Summary

area
x_max
x_min
y_max
y_min

Methods Summary

Hfunction(data, radii[, mode]) Evaluates the H function at radii.
Lfunction(data, radii[, mode]) Evaluates the L function at radii.
__call__(data, radii[, mode]) Call self as a function.
evaluate(data, radii[, mode]) Evaluates the Ripley K estimator for a given set of values radii.
poisson(radii) Evaluates the Ripley K function for the homogeneous Poisson process, also known as Complete State of Randomness (CSR).

Attributes Documentation

area
x_max
x_min
y_max
y_min

Methods Documentation

Hfunction(data, radii, mode='none')[source] [edit on github]

Evaluates the H function at radii. For parameter description see evaluate method.

Lfunction(data, radii, mode='none')[source] [edit on github]

Evaluates the L function at radii. For parameter description see evaluate method.

__call__(data, radii, mode='none')[source] [edit on github]

Call self as a function.

evaluate(data, radii, mode='none')[source] [edit on github]

Evaluates the Ripley K estimator for a given set of values radii.

Parameters:
data : 2D array

Set of observed points in as a n by 2 array which will be used to estimate Ripley’s K function.

radii : 1D array

Set of distances in which Ripley’s K estimator will be evaluated. Usually, it’s common to consider max(radii) < (area/2)**0.5.

mode : str

Keyword which indicates the method for edge effects correction. Available methods are ‘none’, ‘translation’, ‘ohser’, ‘var-width’, and ‘ripley’.

  • ‘none’
    this method does not take into account any edge effects whatsoever.
  • ‘translation’
    computes the intersection of rectangular areas centered at the given points provided the upper bounds of the dimensions of the rectangular area of study. It assumes that all the points lie in a bounded rectangular region satisfying x_min < x_i < x_max; y_min < y_i < y_max. A detailed description of this method can be found on ref [4].
  • ‘ohser’
    this method uses the isotropized set covariance function of the window of study as a weight to correct for edge-effects. A detailed description of this method can be found on ref [4].
  • ‘var-width’
    this method considers the distance of each observed point to the nearest boundary of the study window as a factor to account for edge-effects. See [3] for a brief description of this method.
  • ‘ripley’
    this method is known as Ripley’s edge-corrected estimator. The weight for edge-correction is a function of the proportions of circumferences centered at each data point which crosses another data point of interest. See [3] for a detailed description of this method.
Returns:
ripley : 1D array

Ripley’s K function estimator evaluated at radii.

poisson(radii)[source] [edit on github]

Evaluates the Ripley K function for the homogeneous Poisson process, also known as Complete State of Randomness (CSR).

Parameters:
radii : 1D array

Set of distances in which Ripley’s K function will be evaluated.

Returns:
output : 1D array

Ripley’s K function evaluated at radii.