Created
January 30, 2019 11:40
-
-
Save kagaya/dea9bb9bb1dbe946497c814205801f86 to your computer and use it in GitHub Desktop.
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
functions { | |
vector my_student_t_rng(int N, real nu, real mu, real sigma){ | |
vector[N] Y; | |
for (n in 1:N){ | |
Y[n] = student_t_rng(nu, mu, sigma); | |
} | |
return(Y); | |
} | |
vector my_ZIP_rng(int N, real q, real lambda){ | |
vector[N] Y; | |
int choice; | |
for (n in 1:N){ | |
choice = bernoulli_rng(q); | |
if (choice == 0){ | |
Y[n] = 0; | |
} else { | |
Y[n] = poisson_rng(lambda); | |
} | |
} | |
return(Y); | |
} | |
vector my_gamma_rng(int N, real shape, real scale){ | |
vector[N] Y; | |
for (n in 1:N){ | |
Y[n] = gamma_rng(shape, shape/scale); | |
} | |
return(Y); | |
} | |
vector my_normal_rng(int N, real mu, real sigma){ | |
vector[N] Y; | |
for (n in 1:N){ | |
Y[n] = normal_rng(mu, sigma); | |
} | |
return(Y); | |
} | |
vector my_poisson_rng(int N, real lambda){ | |
vector[N] Y; | |
for (n in 1:N){ | |
Y[n] = poisson_rng(lambda); | |
} | |
return(Y); | |
} | |
vector my_categorical_logit_rng(int N, vector mu){ | |
vector[N] Y; | |
for (n in 1:N){ | |
Y[n] = categorical_logit_rng(mu); | |
} | |
return(Y); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment