Hmm. Looks like that bug may have been fixed, leading to
the unexpected behavior you're seeing.
You have to be careful about what you mean by biased. If
I generate 100 draws from normal(0, 1), it might have a mean
of 0.2. The estimator that then estimes a mean of 0.2 isn't
biased.
It looks like the bug is exactly the opposite of what we
listed now --- it doesn't even take the seed into account.
I'll amend the issue.
But it does look like everything's working as intended as far as RNGs
and samplers are concerned. I amended your program to calculate
the sample mean and sd of the pseudo-random numbers and get this:
data {
int<lower=0> N;
}
transformed data {
vector[N] y;
for (n in 1:N)
y[n] = normal_rng(0, 1);
}
parameters {
real mu;
real<lower = 0> sigma;
}
model {
y ~ normal(mu, sigma);
}
generated quantities {
real mean_y = mean(y);
real sd_y = sd(y);
}
When I set N=100, I indeed see that the RNG is generating a sample
on the high side of average:
N=100:
mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat
mu 0.20 0.00 0.10 -0.01 0.13 0.20 0.27 0.41 4000 1
sigma 1.03 0.00 0.08 0.90 0.98 1.03 1.08 1.19 3676 1
mean_y 0.20 0.00 0.00 0.20 0.20 0.20 0.20 0.20 2 1
sd_y 1.02 0.00 0.00 1.02 1.02 1.02 1.02 1.02 2 1
lp__ -52.42 0.02 1.01 -55.20 -52.82 -52.09 -51.69 -51.44 1796 1
N=1000:
mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat
mu 0.01 0.00 0.03 -0.05 -0.01 0.01 0.03 0.07 3411 1
sigma 0.99 0.00 0.02 0.94 0.97 0.98 1.00 1.03 3672 1
mean_y 0.01 0.00 0.00 0.01 0.01 0.01 0.01 0.01 2 1
sd_y 0.98 0.00 0.00 0.98 0.98 0.98 0.98 0.98 2 1
lp__ -485.32 0.03 1.02 -488.09 -485.70 -484.98 -484.61 -484.35 1485 1