Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposed the dirichlet_multinomial distribution #1389

Merged
merged 1 commit into from
Dec 18, 2023
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
3 changes: 3 additions & 0 deletions src/middle/Stan_math_signatures.ml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ let distributions =
; (full_lpdf_depr, "cauchy", [DVReal; DVReal; DVReal], SoA)
; (full_lpdf_depr, "chi_square", [DVReal; DVReal], SoA)
; ([Lpdf; Log], "dirichlet", [DVectors; DVectors], SoA)
; ([Lpmf], "dirichlet_multinomial", [DIntArray; DVector], AoS)
; (full_lpmf_depr, "discrete_range", [DVInt; DVInt; DVInt], SoA)
; (full_lpdf_depr, "double_exponential", [DVReal; DVReal; DVReal], SoA)
; (full_lpdf_depr, "exp_mod_normal", [DVReal; DVReal; DVReal; DVReal], SoA)
Expand Down Expand Up @@ -1150,6 +1151,8 @@ let () =
bare_types)
(List.range 0 8);
add_unqualified ("dirichlet_rng", ReturnType UVector, [UVector], AoS);
add_unqualified
("dirichlet_multinomial_rng", ReturnType (UArray UInt), [UVector; UInt], AoS);
add_unqualified ("distance", ReturnType UReal, [UVector; UVector], SoA);
add_unqualified ("distance", ReturnType UReal, [URowVector; URowVector], SoA);
add_unqualified ("distance", ReturnType UReal, [UVector; URowVector], SoA);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
data {
int d_int;
array[d_int] int d_int_array;
vector[d_int] d_vector;
}
transformed data {
real transformed_data_real;
transformed_data_real = dirichlet_multinomial_lpmf(d_int_array | d_vector);
}
parameters {
vector[d_int] p_vector;
real y_p;
}
transformed parameters {
real transformed_param_real;
transformed_param_real = dirichlet_multinomial_lpmf(d_int_array | d_vector);
transformed_param_real = dirichlet_multinomial_lpmf(d_int_array | p_vector);
}
model {
y_p ~ normal(0, 1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ generated quantities {
n = categorical_logit_rng(theta);
ns = multinomial_rng(theta, 20);
ns = multinomial_logit_rng(theta, 20);
ns = dirichlet_multinomial_rng(alpha, 20);
x = chi_square_rng(alpha);
x = chi_square_rng(nu);
x = chi_square_rng(ns);
Expand Down
1 change: 1 addition & 0 deletions test/integration/signatures/stan_math_distributions.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Display all Stan math distributions exposed in the language
cauchy: lpdf, rng, ccdf, cdf, log (deprecated)
chi_square: lpdf, rng, ccdf, cdf, log (deprecated)
dirichlet: lpdf, log (deprecated)
dirichlet_multinomial: lpmf
discrete_range: lpmf, rng, ccdf, cdf, log (deprecated)
double_exponential: lpdf, rng, ccdf, cdf, log (deprecated)
exp_mod_normal: lpdf, rng, ccdf, cdf, log (deprecated)
Expand Down
2 changes: 2 additions & 0 deletions test/integration/signatures/stan_math_signatures.t
Original file line number Diff line number Diff line change
Expand Up @@ -4254,6 +4254,8 @@ Display all Stan math signatures exposed in the language
dirichlet_lpdf(array[] row_vector, row_vector) => real
dirichlet_lpdf(array[] row_vector, array[] vector) => real
dirichlet_lpdf(array[] row_vector, array[] row_vector) => real
dirichlet_multinomial_lpmf(array[] int, vector) => real
dirichlet_multinomial_rng(vector, int) => array[] int
dirichlet_rng(vector) => vector
discrete_range_ccdf_log(int, int, int) => real
discrete_range_ccdf_log(int, int, array[] int) => real
Expand Down