ars.new(Runuran)
ars.new()所属R语言包:Runuran
UNU.RAN generator based on Adaptive Rejection Sampling (ARS)
UNU.RAN发生器基于自适应拒绝抽样(ARS)
译者:生物统计家园网 机器人LoveR
描述----------Description----------
UNU.RAN random variate generator for continuous distributions with given probability density function (PDF). It is based on Adaptive Rejection Sampling ("ARS").
UNU.RAN给定的概率密度函数(PDF)的连续分布的随机变量发生器。它是基于自适应拒绝抽样(ARS)。
[Universal] – Rejection Method.
[通用] - 抑制方法。
用法----------Usage----------
ars.new(logpdf, dlogpdf=NULL, lb, ub, ...)
arsd.new(distr)
参数----------Arguments----------
参数:logpdf
log-density function. (R function)
记录密度函数。 (R功能)
参数:dlogpdf
derivative of logpdf. (R function)
衍生工具的logpdf。 (R功能)
参数:lb
lower bound of domain; use -Inf if unbounded from left. (numeric)
域的下界使用-Inf如果左无界。 (数字)
参数:ub
upper bound of domain; use Inf if unbounded from right. (numeric)
上界域;使用Inf,如果无界右。 (数字)
参数:...
(optional) arguments for logpdf.
(可选)参数logpdf。
参数:distr
distribution object. (S4 object of class "unuran.cont")
发行对象。 (S4类的对象"unuran.cont")
Details
详细信息----------Details----------
This function creates a unuran object based on "ARS" (Adaptive Rejection Sampling). It can be used to draw samples from continuous distributions with given probability density function using ur.
这个函数创建一个unuran对象的基础上“ARS”(自适应拒绝抽样)。它可用于,得出样品从给定的概率密度函数的连续分布,使用ur。
Function logpdf is the logarithm the density function of the target distribution. It must be a concave function (i.e., the distribution must be log-concave). However, it need not be normalized (i.e., it can be a log-density plus some arbitrary constant).
函数logpdf目标分布的密度函数的对数。它必须是一个凹函数(例如,分配必须登录凹)。然而,它需要不进行归一(即,它可以是一个记录密度加上一些任意常数)。
The derivative dlogpdf of the log-density is optional. If omitted, numerical differentiation is used. Notice, however, that this might cause some round-off errors such that the algorithm fails.
的衍生物的dlogpdf的记录密度是可选的。如果省略该参数,数值微分。但是请注意,这可能导致一些舍入误差,该算法失败。
Alternatively, one can use function arsd.new where the object distr of class "unuran.cont" must contain all required information about the distribution.
另外,我们可以使用函数arsd.new对象distr类"unuran.cont"的分布必须包含所有需要的信息。
The setup time of this method depends on the given PDF, whereas its marginal generation times are almost independent of the target distribution.
这种方法的建立时间取决于在给定的PDF,而其边际代的时间几乎是独立的目标分配。
"ARS" is a special case of method "TDR" (see tdr.new). It is a bit slower and less flexible but numerically more stable. In particular, it is useful if one wants to sample from truncated distributions with extreme truncation points; or when the integral of the given “density” function is only known to be extremely large or small. However, this assumes that the log-density is computed analytically and not by just using log(pdf(x)).
“ARS”是一个特例法“TDR”(见tdr.new)。这是一个有点慢,不够灵活,但数值上更稳定。特别是,它是有用的,如果一个人想从截断的分布与极端截断点的采样,或当给定的“密度”的函数的积分是唯一已知的非常大或小。然而,这种假设的记录密度计算分析,而不是使用log(pdf(x))。
值----------Value----------
An object of class "unuran".
对象的类"unuran"。
(作者)----------Author(s)----------
Josef Leydold and Wolfgang H\"ormann
<a href="mailto:unuran@statmath.wu.ac.at">unuran@statmath.wu.ac.at</a>.
参考文献----------References----------
Automatic Nonuniform Random Variate Generation. Springer-Verlag, Berlin Heidelberg. See Chapter 4 (Tranformed Density Rejection).
Adaptive rejection sampling for Gibbs sampling. Applied Statistics 41(2), pp. 337–348.
参见----------See Also----------
ur, tdr.new, unuran.cont, unuran.new, unuran.
ur,tdr.new,unuran.cont,unuran.new,unuran。
实例----------Examples----------
## Create a sample of size 100 for a [#创建一个大小为100的样品]
## Gaussian distribution (use logPDF)[#高斯分布(使用logPDF)]
lpdf <- function (x) { -0.5*x^2 }
gen <- ars.new(logpdf=lpdf, lb=-Inf, ub=Inf)
x <- ur(gen,100)
## Same example but additionally provide derivative of log-density[同样的例子,但另外提供衍生的记录密度]
## to prevent possible round-off errors[#以防止可能出现的舍入误差]
lpdf <- function (x) { -0.5*x^2 }
dlpdf <- function (x) { -x }
gen <- ars.new(logpdf=lpdf, dlogpdf=dlpdf, lb=-Inf, ub=Inf)
x <- ur(gen,100)
## Draw a sample from a truncated Gaussian distribution[#截断高斯分布抽取样本]
## on domain [100,Inf)[#在区间[100,天道酬勤)]
lpdf <- function (x) { -0.5*x^2 }
gen <- ars.new(logpdf=lpdf, lb=50, ub=Inf)
x <- ur(gen,100)
## Alternative approach[#另一种方法]
distr <- udnorm()
gen <- arsd.new(distr)
x <- ur(gen,100)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|