R语言dsample包 dsample函数使用说明

返回R语言dsample包函数列表


功能\作用概述:

样品.wl基于Wang-Lee算法,从目标密度函数生成指定大小n的样本(直到规格化常数)


语法\用法:

dsample(expr, rpmat, n = 1000, nk = 10000, wconst)


参数说明:

expr : 表达

rpmat : 含随机点的离散化矩阵

n : 非负整数,即所需的样本大小。

nk : 正整数,轮廓数。请参阅“详细信息”。

wconst : 介于0和1之间的实数。请参阅“详细信息”。


示例\实例:

## The following example is taken from West (1993, page 414).
## West, M. (1993). Approximating posterior distributions by mixture.
## Journal of the Royal Statistical Society - B, 55, 409-422.

expr < - expression((x1*(1-x2))^5 * (x2*(1-x1))^3 * (1-x1*(1-x2)-x2*(1-x1))^37)
sets < - list(x1=runif(1e5), x2=runif(1e5))
smp < - dsample(expr=expr, rpmat=sets, nk=1e4, n=1e3)

##
## More accurate results can be achieved by increasing the number
## of dicretization points and the number of contours.