No vector return from normal_cdf with vector arguments

I want to execute the normal CDF on vector inputs to obtain a vector of cumulative probabilities. However, I am getting a dimension mismatch error. The error says the return on the right-hand side is of type “real”. The Stan documentation says that the cdf function accepts “reals” arguments and has “reals” returns. I thought this psuedotype “reals” included vectors yet it appears to be returning a scalar.

Am I attempting something that is possible or will I need to use a 1:N loop?

Example code:

vector[N] mu;
vector[N] sigma;
vector[N] time;
vector[N] phi;

phi = normal_cdf(time, mu, sigma);

Example error:

Dimension mismatch in assignment; variable name = phi, type = vector; right-hand side type = real.
Illegal statement beginning with non-void expression parsed as

You have to use a loop. This is something that would be useful for copulas as well. You can open an issue in github under stan math to request this functionality.

1 Like

This would be something where a rowise/colwise framework would come in handy, I’ll reopen discussion on that in the design doc PR


Hi everyone!
Should we still use a loop? Or there is another possibility to handle that please?
Thank you in advance!