Skip to content

Instantly share code, notes, and snippets.

@ericnovik
Created April 18, 2023 20:34
Show Gist options
  • Save ericnovik/e7dc23ca84320290409454d6728feb47 to your computer and use it in GitHub Desktop.
Save ericnovik/e7dc23ca84320290409454d6728feb47 to your computer and use it in GitHub Desktop.
data {
int<lower=0> N;
array[N] int<lower=0, upper=1> y;
real<lower=0> a;
real<lower=0> b;
}
parameters {
real<lower=0, upper=1> theta;
}
model {
// beta prior
target += (a - 1) * log(theta) + (b - 1) * log(1 - theta);
// likelihood
for (i in 1:N) {
target += log(theta) * y[i] + log(1 - theta) * (1 - y[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment