rfmc(smfsb)
rfmc()所属R语言包:smfsb
Simulate a finite state space Markov chain
模拟一个有限状态空间马尔可夫链。
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This function simulates a single realisation from a discrete time Markov chain having a finite state space based on a given transition matrix.
此功能模拟的是单实现从一个离散时间马尔可夫链具有有限的状态空间,基于在一个给定的转移矩阵。
用法----------Usage----------
rfmc(n,P,pi0)
参数----------Arguments----------
参数:n
The number of states to be sampled from the Markov chain, including the initial state, which will be sampled using pi0.
从马尔可夫链的状态数进行采样,包括初始状态,将采样使用pi0。
参数:P
The transition matrix of the Markov chain. This is assumed to be a stochastic matrix, having non-negative elements and rows summing to one, though in fact, the rows will in any case be normalised by the sampling procedure.
马尔可夫链的转移矩阵。这被假设为是一个随机矩阵,具有非负的元素和行求和一个,尽管事实上,行会在任何情况下,归一化采样程序。
参数:pi0
A vector representing the probability distribution of the initial state of the Markov chain. If this vector is of length r, then the transition matrix P is assumed to be r x r. The elements of this vector are assumed to be non-negative and sum to one, though in fact, they will be normalised by the sampling procedure.
一个向量Markov链的初始状态的概率分布。如果此向量的长度为r,然后过渡矩阵P被假定为r x r。此向量的元素都被假定为一个非负和sum,尽管事实上,他们将被归一化采样程序。
值----------Value----------
An R ts object containing the sampled values from the Markov chain.
Rts对象,包含采样值的马尔可夫链。
参见----------See Also----------
rcfmc, ts
rcfmc,ts
实例----------Examples----------
# example for sampling a finite Markov chain[例如,采样有限马尔可夫链]
P = matrix(c(0.9,0.1,0.2,0.8),ncol=2,byrow=TRUE)
pi0 = c(0.5,0.5)
samplepath = rfmc(200,P,pi0)
plot(samplepath)
summary(samplepath)
table(samplepath)
table(samplepath)/length(samplepath) # empirical distribution[经验分布]
# now compute the exact stationary distribution...[现在计算精确平稳分布...]
e = eigen(t(P))$vectors[,1]
e/sum(e)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|