gibbs_normal <- function(input, S, seed){
set.seed(seed)
ybar <- mean(input$y)
n <- length(input$y)
para <- matrix(0, S, 2)
phi <- input$phi_init
for(s in 1:S){
theta1 <- (input$theta/input$tau^2 + n*phi*ybar)/
(1/input$tau^2 + n*phi)
tau1 <- sqrt(1/(1/input$tau^2 + n*phi))
mu <- rnorm(1, mean = theta1, sd = tau1)
alpha1 <- input$alpha + n/2
beta1 <- input$beta + sum((input$y - mu)^2)/2
phi <- rgamma(1, shape = alpha1, rate = beta1)
para[s, ] <- c(mu, phi)
}
para
}