stan-dev / math

The Stan Math Library is a C++ template library for automatic differentiation of any order using forward, reverse, and mixed modes. It includes a range of built-in functions for probabilistic modeling, linear algebra, and equation solving.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
724 stars 183 forks source link

categorical_* functions don't accept row_vectors (it would be good that they could) #2443

Open bnicenboim opened 7 years ago

bnicenboim commented 7 years ago

Summary:

The functions for the categorical distribution only accept a column vector, it would be great if it could accept also row vectors.

Description:

I use the categorical distribution to go over a matrix N_obs x N_probabilities, so it's more natural for me to use row vectors than column vectors.

Current functions:

real categorical_lpmf(ints y | vector theta) real categorical_logit_lpmf(ints y | vector beta) int categorical_rng(vector theta)

Expected functions:

real categorical_lpmf(ints y | row_vector theta) real categorical_logit_lpmf(ints y | row_vector beta) int categorical_rng(row_vector theta)

Current Version:

v2.15.0

rok-cesnovar commented 3 years ago

Transferring this old issue form stan-dev/stan. Do we have row_vector support for these in Math? I think we do but just checking. If so we should move this issue to stanc3.

t4c1 commented 3 years ago

Math code looks like it should support row vectors, but I doubt it is tested.