Skip to content

Instantly share code, notes, and snippets.

@cqfd
Created July 31, 2018 21:38
Show Gist options
  • Save cqfd/b5cc3955da4a13600d8af4181f8d286f to your computer and use it in GitHub Desktop.
Save cqfd/b5cc3955da4a13600d8af4181f8d286f to your computer and use it in GitHub Desktop.
Stan model for MacKay's Chapter 3 particle detector example.
data {
int N;
real<lower=1, upper=20> observations[N];
}
parameters {
real<lower=0> lambda;
}
model {
real Z = exp(-1/lambda) - exp(-20/lambda);
for (i in 1:N) {
target += exponential_lpdf(observations[i] | 1/lambda) - log(Z);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment