rshift.psp {spatstat.random} | R Documentation |
Randomly Shift a Line Segment Pattern
Description
Randomly shifts the segments in a line segment pattern.
Usage
## S3 method for class 'psp'
rshift(X, ..., group=NULL, which=NULL)
Arguments
X |
Line segment pattern to be subjected to a random shift.
An object of class |
... |
Arguments controlling the randomisation and the handling of edge
effects. See |
group |
Optional. Factor specifying a grouping of the line segments of |
which |
Optional. Identifies which groups of the pattern will be shifted,
while other groups are not shifted. A vector of levels of |
Details
This operation randomly shifts the locations of the line segments in a line segment pattern.
The function rshift
is generic. This function rshift.psp
is the method for line segment patterns.
The line segments of X
are first divided into groups,
then the line segments within a group are shifted by a common
random displacement vector. Different groups of line segments are shifted
independently.
If the argument group
is present, then this determines the grouping.
Otherwise, all line segments belong to a single group.
The argument group
should be a factor, of length equal to the
number of line segments in X
.
Alternatively group
may be NULL
,
which specifies that all line segments of X
belong to a single group.
By default, every group of line segments will be shifted.
The argument which
indicates that only some of the groups
should be shifted, while other groups should be left unchanged.
which
must be a vector of levels of group
indicating which groups are to be shifted.
The displacement vector, i.e. the vector
by which the data line segments are shifted,
is generated at random.
The default behaviour is
to generate a displacement vector at random with equal probability
for all possible displacements. This means that the x
and
y
coordinates of the displacement vector are independent random
variables, uniformly distributed over the range of possible coordinates.
Alternatively, the displacement vector can be generated by
another random mechanism, controlled by the arguments
radius
, width
and height
.
- rectangular:
-
if
width
andheight
are given, then the displacement vector is uniformly distributed in a rectangle of these dimensions, centred at the origin. The maximum possible displacement in thex
direction iswidth/2
. The maximum possible displacement in they
direction isheight/2
. Thex
andy
displacements are independent. (Ifwidth
andheight
are actually equal to the dimensions of the observation window, then this is equivalent to the default.) - radial:
-
if
radius
is given, then the displacement vector is generated by choosing a random line segment inside a disc of the given radius, centred at the origin, with uniform probability density over the disc. Thus the argumentradius
determines the maximum possible displacement distance. The argumentradius
is incompatible with the argumentswidth
andheight
.
The argument edge
controls what happens when
a shifted line segment lies partially or completely
outside the window of X
. Currently the only option is
"erode"
which specifies that the segments will be clipped
to a smaller window.
The optional argument clip
specifies a smaller window
to which the pattern should be restricted.
Value
A line segment pattern (object of class "psp"
).
Author(s)
Adrian Baddeley Adrian.Baddeley@curtin.edu.au
and Rolf Turner rolfturner@posteo.net
See Also
Examples
X <- psp(runif(20), runif(20), runif(20), runif(20), window=owin())
Y <- rshift(X, radius=0.1)