Created
January 9, 2018 06:44
-
-
Save kosugitti/d7ee9a7ebaa6755cd17e6eaa5d87f919 to your computer and use it in GitHub Desktop.
GPCMの反応確率を求めるコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a <- 1.5 | |
d <- c(-1.5,0,1) | |
K <- 3 | |
pjkt <- function(theta,a,d,k,K){ | |
bunbo <- 0.0 | |
for(m in 0:K){ | |
tmp <- 0.0 | |
for(l in 0:m){ | |
if(l!=0){ | |
tmp <- tmp + (theta - d[[l]]) | |
}else{ | |
tmp <- 0 | |
} | |
} | |
bunbo <- bunbo + exp(a * tmp) | |
} | |
tmp <- 0.0 | |
for(l in 0:k){ | |
if(l!=0){ | |
tmp <- tmp + (theta - d[[l]]) | |
}else{ | |
tmp <- 0 | |
} | |
} | |
bunsi <- exp(a * tmp) | |
return(bunsi/bunbo) | |
} | |
theta <- seq(-4,4,0.01) | |
plot(theta,pjkt(theta,a,d,3,K)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment