StandardLotkaVolterra
n種が、巡回の関係にあるとする。
種の食物連鎖の関係は、腐食も考慮すれば、巡回しているので、このように考える。
各種は「分子量」のように、栄養素に関してユニット数を持つ。
これは、DrawAttractor()の特殊な場合である。
StandardLotkaVolterra(n=5)
StandardLotkaVolterra<-function(n=4,Nrep=30,Niter=1000,dt=0.01,us=NULL){
if(is.null(us)){
us<-rep(1,n)
}
Nr<-n
ks<-runif(Nr)
ks<-rep(1,n)
In<-Player<-diag(n)
Out<-matrix(0,Nr,n)
for(i in 1:Nr){
for(j in 1:n){
if(j==i+1){
Player[i,j]<-1
Out[i,j]<-1
}
}
}
Player[Nr,1]<-Out[Nr,1]<-1
S<-1
P<-runif(1,min=0,max=(1/n)^n)
xssum<-NULL
col<-c()
for(rep in 1:Nrep){
m<-matrix(0,Niter,n)
p<-rep(0,Niter)
p[1]<-0
for(i in 1:n){
p[1]<-p[1]+us[i]*m[1,i]
}
m[1,]<-m[1,]/p[1]
p[1]<-0
for(i in 1:n){
p[1]<-p[1]+us[i]*m[1,i]
}
library(MCMCpack)
m[1,]<-runif(n)
for(i in 2:Niter){
m[i,]<-m[i-1,]
for(j in 1:Nr){
tmp<-ks[j]*dt
pamountIn<-0
pamountOut<-0
for(k in 1:n){
tmp<-tmp*m[i-1,k]^Player[j,k]
pamountIn<-pamountIn+us[k]*In[j,k]
pamountOut<-pamountOut+us[k]*Out[j,k]
}
for(k in 1:n){
m[i,k]<-m[i,k]-In[j,k]*tmp+tmp*pamountIn/pamountOut*us[k]*Out[j,k]/pamountOut*Out[j,k]
}
}
for(j in 1:n){
p[i]<-p[i]+us[j]*m[i,j]
}
}
xs<-matrix(0,Niter,n-1)
cv<-CategoryVector(n)
for(i in 1:Niter){
for(j in 1:n){
xs[i,]<-xs[i,]+m[i,j]*cv[j,]
}
}
xssum<-rbind(xssum,xs)
col<-c(col,rep(rep,Niter))
}
plot3d(xssum[,1],xssum[,2],xssum[,3],col=col)
list(X=xssum,col=col)
}
\name{StandardLotkaVolterra}
\alias{StandardLotkaVolterra}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
StandardLotkaVolterra
}
\description{
n種が、巡回の関係にあるとする。
種の食物連鎖の関係は、腐食も考慮すれば、巡回しているので、このように考える。
各種は「分子量」のように、栄養素に関してユニット数を持つ。
これは、DrawAttractor()の特殊な場合である。
}
\usage{
StandardLotkaVolterra(n=4)
}
%- maybe also 'usage' for other objects documented here.
\details{
%% ~~ If necessary, more details than the description above ~~
}
\value{
\item{X}{matrix of No. time points x No. species representing No. species }
}
\references{
%% ~put references to the literature/web site here ~
}
\author{
%% ~~who you are~~
}
\note{
%% ~~further notes~~
}
%% ~Make other sections like Warning with \section{Warning }{....} ~
\seealso{
DrawAttractor
}
\examples{
n<-4
lv<-StandardLotkaVolterra(n)
plot3d(lv$X[,1],lv$X[,2],lv$X[,3],col=lv$col)
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ ~kwd1 }
\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line