Skip to content

Instantly share code, notes, and snippets.

@kosugitti
Created December 21, 2016 00:57
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/ed08dd0c744931db9a600e0125b9b435 to your computer and use it in GitHub Desktop.
Save kosugitti/ed08dd0c744931db9a600e0125b9b435 to your computer and use it in GitHub Desktop.
NUTSアルゴリズムにバグがあると聞いて
model <- '
parameters {
vector[2] z;
}
model{
matrix[2,2] sigma;
vector[2] mu;
mu[1] <- 0.0;
mu[2] <- 3.0;
sigma[1][1] <- 1.0 * 1.0;
sigma[1][2] <- 0.5 * 1.0 * 2.0;
sigma[2][1] <- 0.5 * 1.0 * 2.0;
sigma[2][2] <- 2.0 * 2.0;
z ~ multi_normal(mu, sigma);
}
'
testing.model <- stan_model(model_code=model)
fit1 <- sampling(testing.model,iter=1000000,warmup=100000,algorithm="HMC")
fit2 <- sampling(testing.model,iter=1000000,warmup=100000,algorithm="NUTS")
print(fit1)
print(fit2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment