Skip to content

Instantly share code, notes, and snippets.

@kosugitti
Created January 9, 2018 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kosugitti/d7ee9a7ebaa6755cd17e6eaa5d87f919 to your computer and use it in GitHub Desktop.
Save kosugitti/d7ee9a7ebaa6755cd17e6eaa5d87f919 to your computer and use it in GitHub Desktop.
GPCMの反応確率を求めるコード
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