找回密码
 注册
查看: 240|回复: 0

R语言 SparseGrid包 createSparseGrid()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-30 12:30:22 | 显示全部楼层 |阅读模式
createSparseGrid(SparseGrid)
createSparseGrid()所属R语言包:SparseGrid

                                         Create sparse grid
                                         创建稀疏网格

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Creates nodes and weights that can be used for sparse grid integration. Based on Matlab code by Florian Heiss and Viktor Winschel, available from http://www.sparse-grids.de
创建节点和重量可用于稀疏电网整合。基于Matlab的代码由Florian海斯和维克托Winschel的,可从http://www.sparse-grids.de的


用法----------Usage----------


createSparseGrid(type, dimension, k, sym = FALSE)



参数----------Arguments----------

参数:type
String or function for type of 1D integration rule, can take on values     
字符串或函数类型的一维积分规则,可以采取的值

"KPU"Nested rule for unweighted integral over [0,1]  
"KPU"嵌套的未加权积分规则[0,1]

"KPN"Nested rule for integral with Gaussian weight  
"KPN"高斯重量为一体的嵌套规则

"GQU"Gaussian quadrature for unweighted integral over [0,1] (Gauss-Legendre)  
"GQU"高斯积分未加权积分来[0,1](高斯 - 勒让德)

"GQN"Gaussian quadrature for integral with Gaussian weight (Gauss-Hermite)  
"GQN"高斯积分为一体的重量高斯(高斯 - 厄米特)

funcany function. Function must accept level k and return a list with two elements nodes and weights for univariate quadrature rule with polynomial exactness 2k-1.     
func任何功能。函数必须接受k层,并返回一个列表有两个元素的nodes和weights规则进行单因素正交多项式的正确性2K-1。


参数:dimension
dimension of the integration problem.  
维度的整合问题。


参数:k
Accuracy level. The rule will be exact for polynomial up to total order 2k-1.  
的精度水平。多项式总阶为2k-1的规则将是精确的。


参数:sym
(optional) only used for own 1D quadrature rule (type not "KPU",...). If sym is supplied and not FALSE, the code will run faster but will produce incorrect results if 1D quadrature rule is asymmetric.  
(可选)仅用于自己的一维正交规则(类型不是“KPU”,...)。如果SYM提供不假,代码将运行得更快,但会产生不正确的结果,如果一维正交规则是不对称的。


值----------Value----------

The return value contains a list with nodes and weights
返回值将包含一个列表,节点和权重


参数:nodes
matrix with a node in each row
矩阵与每行中的一个节点


参数:weights
vector with corresponding weights
与相应的权重向量


(作者)----------Author(s)----------



Jelmer Ypma




参考文献----------References----------



参见----------See Also----------

createProductRuleGrid createMonteCarloGrid createIntegrationGrid integrate pmvnorm
createProductRuleGridcreateMonteCarloGridcreateIntegrationGridintegratepmvnorm


实例----------Examples----------


# load library[加载库]
library('SparseGrid')

# define function to be integrated[定义函数以被集成]
# g(x) = x[1] * x[2] * ... * x[n][G(X)= [1] *×[2] * ... * x〔n〕]
g <- function( x ) {
        return( prod( x ) )
}

#[]
# Create sparse integration grid to approximate integral of a function with uniform weights[创建稀疏网格来近似积分的功能整合统一的重量]
#[]
sp.grid <- createSparseGrid( 'KPU', dimension=3, k=5 )

# number of nodes and weights[的节点数目和重量]
length( sp.grid$weights )

# evaluate function g in nodes[评估函数g节点]
gx.sp <- apply( sp.grid$nodes, 1, g )

# take weighted sum to get approximation for the integral[加权求和得到近似的积分]
val.sp <- gx.sp %*% sp.grid$weights

#[]
# Create integration grid to approximate integral of a function with uniform weights[集成网格创建一个函数的近似积分统一的重量]
#[]
pr.grid <- createProductRuleGrid( 'KPU', dimension=3, k=5 )

# number of nodes and weights[的节点数目和重量]
length( pr.grid$weights )

# evaluate function g in nodes[评估函数g节点]
gx.pr <- apply( pr.grid$nodes, 1, g )

# take weighted sum to get approximation for the integral[加权求和得到近似的积分]
val.pr <- gx.pr %*% pr.grid$weights

#[]
# Create integration grid to approximation integral using Monte Carlo simulation[创建集成的网格,使用蒙特卡罗模拟近似积分]
#[]
set.seed( 3141 )
mc.grid <- createMonteCarloGrid( runif, dimension=3, num.sim=1000 )

# number of nodes and weights[的节点数目和重量]
length( mc.grid$weights )

# evaluate function g in MC nodes[MC节点评价函数g]
gx.mc   <- apply( mc.grid$nodes, 1, g )

# take weighted sum to get approximation for the integral[加权求和得到近似的积分]
# the weights are all equal to 1/1000 in this case[的权重全部相等,在这种情况下,以1/1000]
val.mc <- gx.mc %*% mc.grid$weights

val.sp
val.pr
val.mc

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-6-9 19:56 , Processed in 0.037930 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表