Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rthin

Random Thinning


Description

Applies independent random thinning to a point pattern or segment pattern.

Usage

rthin(X, P, ..., nsim=1, drop=TRUE)

Arguments

X

A point pattern (object of class "ppp" or "lpp" or "pp3" or "ppx") or line segment pattern (object of class "psp") that will be thinned.

P

Data giving the retention probabilities, i.e. the probability that each point or line in X will be retained. Either a single number, or a vector of numbers, or a function(x,y) in the R language, or a function object (class "funxy" or "linfun"), or a pixel image (object of class "im" or "linim").

...

Additional arguments passed to P, if it is a function.

nsim

Number of simulated realisations to be generated.

drop

Logical. If nsim=1 and drop=TRUE (the default), the result will be a point pattern, rather than a list containing a point pattern.

Details

In a random thinning operation, each point of the point pattern X is randomly either deleted or retained (i.e. not deleted). The result is a point pattern, consisting of those points of X that were retained.

Independent random thinning means that the retention/deletion of each point is independent of other points.

The argument P determines the probability of retaining each point. It may be

a single number,

so that each point will be retained with the same probability P;

a vector of numbers,

so that the ith point of X will be retained with probability P[i];

a function P(x,y),

so that a point at a location (x,y) will be retained with probability P(x,y);

an object of class "funxy" or "linfun",

so that points in the pattern X will be retained with probabilities P(X);

a pixel image,

containing values of the retention probability for all locations in a region encompassing the point pattern.

If P is a function P(x,y), it should be ‘vectorised’, that is, it should accept vector arguments x,y and should yield a numeric vector of the same length. The function may have extra arguments which are passed through the ... argument.

Value

An object of the same kind as X if nsim=1, or a list of such objects if nsim > 1.

Reproducibility

The algorithm for random thinning was changed in spatstat version 1.42-3. Set spatstat.options(fastthin=FALSE) to use the previous, slower algorithm, if it is desired to reproduce results obtained with earlier versions.

Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner r.turner@auckland.ac.nz and Ege Rubak rubak@math.aau.dk.

Examples

plot(redwood, main="thinning")
  
  # delete 20% of points
  Y <- rthin(redwood, 0.8)
  points(Y, col="green", cex=1.4)

  # function
  f <- function(x,y) { ifelse(x < 0.4, 1, 0.5) }
  Y <- rthin(redwood, f)

  # pixel image
  Z <- as.im(f, Window(redwood))
  Y <- rthin(redwood, Z)


  # thin other kinds of patterns
  E <- rthin(osteo$pts[[1]], 0.6)
  L <- rthin(copper$Lines, 0.5)

spatstat.core

Core Functionality of the 'spatstat' Family

v2.1-2
GPL (>= 2)
Authors
Adrian Baddeley [aut, cre], Rolf Turner [aut], Ege Rubak [aut], Kasper Klitgaard Berthelsen [ctb], Achmad Choiruddin [ctb], Jean-Francois Coeurjolly [ctb], Ottmar Cronie [ctb], Tilman Davies [ctb], Julian Gilbey [ctb], Yongtao Guan [ctb], Ute Hahn [ctb], Kassel Hingee [ctb], Abdollah Jalilian [ctb], Marie-Colette van Lieshout [ctb], Greg McSwiggan [ctb], Tuomas Rajala [ctb], Suman Rakshit [ctb], Dominic Schuhmacher [ctb], Rasmus Plenge Waagepetersen [ctb], Hangsheng Wang [ctb]
Initial release
2021-04-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.