Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/docs/stan-reference/distributions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,12 @@ \subsubsection{Stan Functions}
categorical variate with $N$-simplex distribution parameter
\farg{theta}; may only be used in generated quantities block}
\end{description}


%
\begin{description}
\fitem{int}{categorical\_logit\_rng}{vector \farg{beta}}{Generate a
categorical variate with outcome in range $1:N$ from log-odds vector
\farg{beta}; may only be used in generated quantities block}
\end{description}

\section{Ordered Logistic Distribution}

Expand Down
2 changes: 1 addition & 1 deletion src/docs/stan-reference/examples.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5145,7 +5145,7 @@ \subsection{Discrete Sampling}
\begin{stancode}
generated quantities {
int<lower=1,upper=T> s;
s = categorical_rng(softmax(lp));
s = categorical_logit_rng(lp);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks for catching this.

}
\end{stancode}
%
Expand Down
1 change: 1 addition & 0 deletions src/stan/lang/function_signatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ for (size_t i = 0; i < int_vector_types.size(); ++i) {
VECTOR_T);
}
add("categorical_rng", INT_T, VECTOR_T);
add("categorical_logit_rng", INT_T, VECTOR_T);
for (size_t i = 0; i < vector_types.size(); ++i) {
for (size_t j = 0; j < vector_types.size(); ++j) {
for (size_t k = 0; k < vector_types.size(); ++k) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ generated quantities {
n <- poisson_log_rng(2.7);

n <- categorical_rng(theta);
n <- categorical_logit_rng(theta);
ns <- multinomial_rng(theta,20);

z <- normal_rng(0,1);
Expand Down