Vectorized cumulative normal distribution output

Is there a way to get the result of a vectorized probability functions not as the sum of all evaluations? I want to avoid a for loop over cumulative normal distributions and write something like this:

lt += bernoulli_lpmf(choice[:Tr] | normal_cdf(0, to_vector(delta[:Tr]), weber * to_vector(Total[:Tr])));

instead of:

for (t in Tr) {
      lt += bernoulli_lpmf(choice[t] | normal_cdf(0,delta[t], weber *(Total[t])));
}

Thanks!!

Hey there!

Not sure, but I think you could try something like this?

vector[Tr] z = - to_vector(delta[:Tr]) ./ (weber * to_vector(Total[:Tr])); // could be more clever 
lt += bernoulli_lpmf(choice[:Tr] | Phi(z));

basically standardizing first, then using the standard normal cdf Phi which returns a vector.

Cheers,
Max

1 Like

Thanks! Great idea :)