[過去ログ] 臨床統計もおもしろいですよ、その2 (1002レス)
上下前次1-新
このスレッドは過去ログ倉庫に格納されています。
次スレ検索 歴削→次スレ 栞削→次スレ 過去ログメニュー
886: 2020/01/30(木)23:53 ID:m/EdOA9B(6/6) AAS
こっちは、モンテカルロによるシミュレーション
# Reed-Frost and Greenwood epidemic models
# written by Dennis Chao (1/2009)
# reedfrost - the Reed-Frost epidemic model
# p = probability of transmission
# I0 = initial number of infecteds
# S0 = initial number of susceptibles
# n = number of trials
# greenwood = set to TRUE for the Greenwood model, otherwise run Reed-Frost
# outputs the number of infected and susceptibles over time (as I and S)
reedfrost <- function(p, I0, S0, n, greenwood=FALSE) {
S <- St <- rep(S0, n)
I <- It <- rep(I0, n)
q <- 1-p
time <- 0
while (sum(It)>0) {
if (greenwood)
It <- rbinom(n, St, ifelse(It>0 p, 0))
else
It <- rbinom(n, St, 1-(q^It))
St <- St-It
I <- rbind(I, It)
S <- rbind(S, St)
time <- time+1
}
I <- as.matrix(I)
S <- as.matrix(S)
list(I0=I0,S0=S0,p=p,n=n,I=I,S=S)
}
上下前次1-新書関写板覧索設栞歴
あと 116 レスあります
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル
ぬこの手 ぬこTOP 0.006s