a little clarification on the above example - which is entirely correct -
as this issue just bubbled up again - Minor typos in Stan user guide · Issue #208 · stan-dev/docs · GitHub
intuitively, one would want yrep to be of type vector[N] just as y is.
however, this doesn’t compile.
the definition of normal_rng in the Stan Functions Reference Manual - Stan Functions Reference
says:
Rnormal_rng(reals mu, reals sigma)
Generate a normal variate with location mu and scale sigma; may only be used in transformed data and generated quantities blocks. For a description of argument and return types, see section vectorized PRNG functions.
that definition uses type R - in the prng-vectorization section, 10.8.3.3 Return type - it says:
The result of a vectorized PRNG function depends on the size of the arguments and the distribution’s support. If all arguments are scalars, then the return type is a scalar. For a continuous distribution, if there are any non-scalar arguments, the return type is a real array (
real[]) matching the size of any of the non-scalar arguments, as all non-scalar arguments must have matching size. Discrete distributions returnintsand continuous distributions returnreals, each of appropriate size. The symbolRdenotes such a return type.
in short, the vectorized RNG function normal_rng return scalars or int or real arrays. not matrix, vector, or row_vector.