Random number generation

Hi, I tried the simple model below to generate random samples, but it fails: Warning: Stan seems to have exited badly… Stan gets stuck, returns nothing.

Seeking input on what is wrong with the code. Thanks

data {
int<lower=0> N; //extract number of sampling depths
vector[N] fdat; //extract data
vector[N] ferr; //extract errors
parameters {
vector[N] fdat_new;
model {
fdat ~ normal(fdat_new, ferr);
generated quantities{
vector[N] fdat_pred;
for(n in 1:N) {
fdat_pred[n] = normal_rng(fdat_new[n], ferr[n]);

That code seems fine. Can you run other Stan examples?

Thank you for the response. I found out I was making a mistake when calling Stan (mislabeled N in my data array). I’m surprised Stan does not return an informative error message like “N not found” or something like that.

Do you know if and how much warmup Stan wants in a situation like this when we’re not really trying to fit to anything? I used 100 warmup for 1000 iterations. I’m wondering if the sampling works differently in any way depending on the warmup size?

Yes, NUTS does have different output depending on the number of warmup iterations, but when just drawing from the prior predictive distribution, it should not take that many iterations for NUTS to adapt in most cases. So, in your situation, I would be setting warmup to about 300 or whatever is the minimum to get rid of the messages about the windows being too small and then check the results afterward to make sure they are reasonable.