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

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

[复制链接]
发表于 2012-9-30 02:36:19 | 显示全部楼层 |阅读模式
CA(simecol)
CA()所属R语言包:simecol

                                        Stochastic Cellular Automaton
                                         随机元胞自动机

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

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

simecol example: This model simulates a stochastic cellular automaton.
simecol例如:该模型模拟了一个随机元胞自动机。


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


data(conway)



格式----------Format----------

An S4 object according to the gridModel specification. The object contains the following slots:
S4的对象根据gridModel规格的。该对象包含以下插槽:




main functions with the state transition rules of Coway's Game of Life.
main功能与状态转移规则科威的生命游戏。




parms a list with two vector elements:
parms两个向量元素的列表:




pbirth probability of birth,
pbirth出生的概率,




pdeath death probability, dependend on neighbors.
pdeath死亡概率,时效关系的邻居。




times number of time steps to be simulated.
times的时间步数进行模拟。




init a matrix, giving the initial state of the cellular grid (default: rectangle in the middle of the grid).
init的矩阵,给蜂窝网格的初始状态(默认值:矩形网格的中间)。


Details

详细信息----------Details----------

To see all details, please have a look into the implementation below.
要查看所有详细信息,请看看下面进入实施。


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

sim, parms, init, times.
sim,parms,init,times。


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


##============================================[#============================================]
## Basic Usage:[#的基本用法:]
##   work with the example[#与范例]
##============================================[#============================================]
data(CA)
times(CA)["to"] <- 10
plot(sim(CA))

set.seed(345)
times(CA)["to"] <- 50
CA <- sim(CA)

library(lattice)
tcol <- (terrain.colors(13))[-13]
x <- out(CA, last=TRUE)
x <- ifelse(x == 0, NA, x)
levelplot(x,
  cuts = 11,
  col.regions = tcol,
  colorkey = list(at = seq(0, 55, 5))
)

##============================================[#============================================]
## Implementation:[#实现:]
##   The code of the CA model[#代码的CA模型]
##============================================[#============================================]
CA <- new("gridModel",
  main = function(time, init, parms) {
    z     <- init
    nb    <- eightneighbors(z)
    pgen  <- 1 - (1 - parms$pbirth)^nb
    zgen  <- ifelse(z == 0 &amp;
               runif(z) < pgen, 1, 0)
    zsurv <- ifelse(z >= 1 &amp;
               runif(z) < (1 - parms$pdeath),
               z + 1, 0)
    zgen + zsurv
  },
  parms = list(pbirth = 0.02, pdeath = 0.01),
  times = c(from = 1, to = 50, by = 1),
  init = matrix(0, nrow = 40, ncol = 40),
  solver = "iteration"
)
init(CA)[18:22,18:22] <- 1
##============================================[#============================================]

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-24 01:24 , Processed in 0.028310 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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