rmpoint(spatstat)
rmpoint()所属R语言包:spatstat
Generate N Random Multitype Points
生成N个随机多类型点
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Generate a random multitype point pattern with a fixed number of points, or a fixed number of points of each type.
产生一个随机的多类型固定数目的点,或每种类型的固定数目的点的点图案。
用法----------Usage----------
rmpoint(n, f=1, fmax=NULL, win=unit.square(),
types, ptypes,
..., giveup=1000, verbose=FALSE)
参数----------Arguments----------
参数:n
Number of marked points to generate. Either a single number specifying the total number of points, or a vector specifying the number of points of each type.
标记点来生成数。无论是一个单一的数字指定的点的总数,或指定每种类型的数目的点的矢量。
参数:f
The probability density of the multitype points, usually un-normalised. Either a constant, a vector, a function f(x,y,m, ...), a pixel image, a list of functions f(x,y,...) or a list of pixel images.
概率密度的多类型,通常未归。一个常量,一个向量,一个功能f(x,y,m, ...),一个像素的图像,功能f(x,y,...)或像素的图像列表的列表。
参数:fmax
An upper bound on the values of f. If missing, this number will be estimated.
一个上界的值f。如果缺少,这一数字将估计。
参数:win
Window in which to simulate the pattern. Ignored if f is a pixel image or list of pixel images.
在模拟模式的窗口。如果忽略f是一个像素的图像的像素的图像。
参数:types
All the possible types for the multitype pattern.
所有可能的类型为多类型的模式。
参数:ptypes
Optional vector of probabilities for each type.
可为每种类型的概率向量。
参数:...
Arguments passed to f if it is a function.
参数传递给f,如果它是一个函数。
参数:giveup
Number of attempts in the rejection method after which the algorithm should stop trying to generate new points.
在抑制方法的尝试之后,算法应该停止试图产生新的点的数目。
参数:verbose
Flag indicating whether to report details of performance of the simulation algorithm.
标志,指示是否要报告的模拟算法的性能的详细信息。
Details
详细信息----------Details----------
This function generates random multitype point patterns consisting of a fixed number of points.
这个函数生成一个固定数量的点组成的的随机多类型的点图案。
Three different models are available:
三种不同的模式可供选择:
If n is a single number and the argument ptypes is missing, then n independent, identically distributed random multitype points are generated. Their locations (x[i],y[i]) and types m[i] have joint probability density proportional to f(x,y,m).
n如果是单数和参数ptypes缺少,那么n独立,同分布的随机多类型点的产生。它们的位置(x[i],y[i])和类型m[i]的联合概率密度成正比,f(x,y,m)。
If n is a single number and ptypes is given, then n independent, identically distributed random multitype points are generated. Their types m[i] have probability distribution ptypes. Given the types, the locations (x[i],y[i]) have conditional probability density proportional to f(x,y,m).
n如果是单数和ptypes,然后n独立,同分布的随机多类型生成点。它们的类型m[i]概率分布ptypes。给定的类型,位置(x[i],y[i])具有条件概率密度成比例的f(x,y,m)。
If n is a vector, then we generate n[i] independent, identically distributed random points of type types[i]. For points of type m the conditional probability density of location (x,y) is proportional to f(x,y,m).
如果n是一个向量,然后我们产生n[i]独立,同分布的随机点的类型types[i]。点的类型m的条件概率密度的位置(x,y)是比例f(x,y,m)。
Note that the density f is normalised in different ways in Model I and Models II and III. In Model I the normalised joint density is g(x,y,m)=f(x,y,m)/Z where
需要注意的是密度f归以不同的方式在模型I和模型II和III。在I型的归一化的联合密度是g(x,y,m)=f(x,y,m)/Z其中
while in Models II and III the normalised conditional density is g(x,y|m) = f(x,y,m)/Z[m] where
而在模型II和III的归一化条件密度是g(x,y|m) = f(x,y,m)/Z[m]在哪儿
In Model I, the marginal distribution of types is p[m] = Z[m]/Z.
在I型,边缘分布的类型是p[m] = Z[m]/Z。
The unnormalised density f may be specified in any of the following ways.
可以通过以下方式在任何指定的unnormalised密度f。
If f is a single number, the conditional density of location given type is uniform. That is, the points of each type are uniformly distributed. In Model I, the marginal distribution of types is also uniform (all possible types have equal probability).
如果f是单数,位置给定类型的条件密度是一致的。也就是说,每种类型的点是均匀分布的。在I型,边缘分布,类型也是一致的(所有可能的类型有相同的概率)。
If f is a numeric vector, the conditional density of location given type is uniform. That is, the points of each type are uniformly distributed. In Model I, the marginal distribution of types is proportional to the vector f. In Model II, the marginal distribution of types is ptypes, that is, the values in f are ignored.
如果f是一个数值向量,位置给定类型的条件密度是均匀的。也就是说,每种类型的点是均匀分布的。在模型I,类型的边缘分布是成正比的向量f。 II型,边缘分布类型ptypes,也就是说,中的值f会被忽略。
If f is a function, it will be called in the form f(x,y,m,...) at spatial location (x,y) for points of type m. In Model I, the joint probability density of location and type is proportional to f(x,y,m,...). In Models II and III, the conditional probability density of location (x,y) given type m is proportional to f(x,y,m,...). The function f must work correctly with vectors x, y and m, returning a vector of function values. (Note that m will be a factor with levels types.) The value fmax must be given and must be an upper bound on the values of f(x,y,m,...) for all locations (x, y) inside the window win and all types m. The argument types must be given.
如果f是一个函数,它会被调用的形式f(x,y,m,...)在空间位置(x,y)的类型m点。在模型I,联合概率密度分布的位置和类型是比例f(x,y,m,...)。在模型II和III的条件概率密度的位置(x,y)给定类型的m是比例f(x,y,m,...)。 f的功能必须正常工作与向量x,y和m,返回函数值的向量。 (注mtypes。)的价值fmax必须和必须f(x,y,m,...)的所有位置的值是一个上限,将是一个因素与水平(x, y)窗口内的win和各类m。参数types必须提供。
If f is a list of functions, then the functions will be called in the form f[[i]](x,y,...) at spatial location (x,y) for points of type types[i]. In Model I, the joint probability density of location and type is proportional to f[[m]](x,y,...). In Models II and III, the conditional probability density of location (x,y) given type m is proportional to f[[m]](x,y,...). The function f[[i]] must work correctly with vectors x and y, returning a vector of function values. The value fmax must be given and must be an upper bound on the values of f[[i]](x,y,...) for all locations (x, y) inside the window win. The argument types defaults to seq(f).
如果f是一个功能列表,然后将功能要求的形式f[[i]](x,y,...)在空间位置(x,y)的类型types[i]点。在模型I,联合概率密度分布的位置和类型是比例f[[m]](x,y,...)。在模型II和III的条件概率密度的位置(x,y)给定类型的m是比例f[[m]](x,y,...)。 f[[i]]的功能必须正常工作与向量x和y,返回函数值的向量。值fmax必须,必须有一个上限的值f[[i]](x,y,...)的所有位置(x, y)窗口内的win。参数types默认到seq(f)。
If f is a pixel image object of class "im" (see im.object), the unnormalised density at a location (x,y) for points of any type is equal to the pixel value of f for the pixel nearest to (x,y). In Model I, the marginal distribution of types is uniform. The argument win is ignored; the window of the pixel image is used instead. The argument types must be given.
如果f是类的对象的像素的图像"im"(见im.object),unnormalised密度的位置处(x,y)点的任何类型的像素值是等于f最近(x,y)的像素。在I型,边缘分布,类型是一致的。参数win被忽略的窗口像素的图像来代替。参数types必须提供。
If f is a list of pixel images, then the image f[[i]] determines the density values of points of type types[i]. The argument win is ignored; the window of the pixel image is used instead. The argument types defaults to factor(seq(f)).
如果f是一个列表像素图像,图像f[[i]]的决定类型types[i]点的密度值。参数win被忽略的窗口像素的图像来代替。参数types默认到factor(seq(f))。
The implementation uses the rejection method. For Model I, rmpoispp is called repeatedly until n points have been generated. It gives up after giveup calls if there are still fewer than n points. For Model II, the types are first generated according to ptypes, then the locations of the points of each type are generated using rpoint. For Model III, the locations of the points of each type are generated using rpoint.
在实现中使用的抑制方法。对于型号我,rmpoispp反复调用,直到n点已经产生。它放弃后giveup调用,如果仍然有不到n点。对于II型,类型首先生成的根据ptypes,然后每种类型的点的位置,使用rpoint。对于III型,每种类型的点的位置产生的使用rpoint。
值----------Value----------
The simulated point pattern (an object of class "ppp").
的模拟点模式(类的一个对象"ppp"“)。
(作者)----------Author(s)----------
Adrian Baddeley
<a href="mailto:Adrian.Baddeley@csiro.au">Adrian.Baddeley@csiro.au</a>
<a href="http://www.maths.uwa.edu.au/~adrian/">http://www.maths.uwa.edu.au/~adrian/</a>
and Rolf Turner
<a href="mailto:r.turner@auckland.ac.nz">r.turner@auckland.ac.nz</a>
参见----------See Also----------
ppp.object, owin.object
ppp.object,owin.object
实例----------Examples----------
abc <- c("a","b","c")
##### Model I[####模型,我]
rmpoint(25, types=abc)
rmpoint(25, 1, types=abc)
# 25 points, equal probability for each type, uniformly distributed locations[25点,为每个类型的概率相等,均匀分布的位置]
rmpoint(25, function(x,y,m) {rep(1, length(x))}, types=abc)
# same as above[与上述相同]
rmpoint(25, list(function(x,y){rep(1, length(x))},
function(x,y){rep(1, length(x))},
function(x,y){rep(1, length(x))}),
types=abc)
# same as above[与上述相同]
rmpoint(25, function(x,y,m) { x }, types=abc)
# 25 points, equal probability for each type,[25分,每种类型的概率相等,]
# locations nonuniform with density proportional to x[地点不均匀的密度正比于x]
rmpoint(25, function(x,y,m) { ifelse(m == "a", 1, x) }, types=abc)
rmpoint(25, list(function(x,y) { rep(1, length(x)) },
function(x,y) { x },
function(x,y) { x }),
types=abc)
# 25 points, UNEQUAL probabilities for each type,[25点,为每种类型的不等概率,]
# type "a" points uniformly distributed,[“a”型点均匀分布的,]
# type "b" and "c" points nonuniformly distributed.[键入“B”和“C”点非均匀分布。]
##### Model II[####II型]
rmpoint(25, 1, types=abc, ptypes=rep(1,3)/3)
rmpoint(25, 1, types=abc, ptypes=rep(1,3))
# 25 points, equal probability for each type,[25分,每种类型的概率相等,]
# uniformly distributed locations[均匀分布的位置]
rmpoint(25, function(x,y,m) {rep(1, length(x))}, types=abc, ptypes=rep(1,3))
# same as above[与上述相同]
rmpoint(25, list(function(x,y){rep(1, length(x))},
function(x,y){rep(1, length(x))},
function(x,y){rep(1, length(x))}),
types=abc, ptypes=rep(1,3))
# same as above[与上述相同]
rmpoint(25, function(x,y,m) { x }, types=abc, ptypes=rep(1,3))
# 25 points, equal probability for each type,[25分,每种类型的概率相等,]
# locations nonuniform with density proportional to x[地点不均匀的密度正比于x]
rmpoint(25, function(x,y,m) { ifelse(m == "a", 1, x) }, types=abc, ptypes=rep(1,3))
# 25 points, EQUAL probabilities for each type,[25点,等于为每个类型的概率,]
# type "a" points uniformly distributed,[“a”型点均匀分布的,]
# type "b" and "c" points nonuniformly distributed.[键入“B”和“C”点非均匀分布。]
###### Model III[#####III型]
rmpoint(c(12, 8, 4), 1, types=abc)
# 12 points of type "a",[“a”型的12个点,]
# 8 points of type "b",[8点“b”型,]
# 4 points of type "c",[4个点的“C”型,]
# each uniformly distributed[每个均匀分布]
rmpoint(c(12, 8, 4), function(x,y,m) { ifelse(m=="a", 1, x)}, types=abc)
rmpoint(c(12, 8, 4), list(function(x,y) { rep(1, length(x)) },
function(x,y) { x },
function(x,y) { x }),
types=abc)
# 12 points of type "a", uniformly distributed[“a”型的,均匀分布的12个点]
# 8 points of type "b", nonuniform[“b”型,非均匀的8点]
# 4 points of type "c", nonuniform[“C”型,不均匀的4点]
#########[########]
## Randomising an existing point pattern:[#弄乱现有的模式:]
data(demopat)
X <- demopat
# same numbers of points of each type, uniform random locations (Model III)[相同数目的点每种类型的,均匀分布的随机位置(III型)]
rmpoint(table(X$marks), 1, types=levels(X$marks), win=X$window)
# same total number of points, distribution of types estimated from X,[相同点的总数,估计从X的类型分布,]
# uniform random locations (Model II)[均匀分布的随机位置(II型)]
rmpoint(X$n, 1, types=levels(X$marks), win=X$window,
ptypes=table(X$marks))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|