Skip to content

Commit 073e29f

Browse files
committed
exposed dirichlet_multinomial distribution
1 parent 6de5732 commit 073e29f

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

src/middle/Stan_math_signatures.ml

+3
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ let distributions =
235235
; (full_lpdf_depr, "cauchy", [DVReal; DVReal; DVReal], SoA)
236236
; (full_lpdf_depr, "chi_square", [DVReal; DVReal], SoA)
237237
; ([Lpdf; Log], "dirichlet", [DVectors; DVectors], SoA)
238+
; ([Lpmf], "dirichlet_multinomial", [DIntArray; DVector], AoS)
238239
; (full_lpmf_depr, "discrete_range", [DVInt; DVInt; DVInt], SoA)
239240
; (full_lpdf_depr, "double_exponential", [DVReal; DVReal; DVReal], SoA)
240241
; (full_lpdf_depr, "exp_mod_normal", [DVReal; DVReal; DVReal; DVReal], SoA)
@@ -1150,6 +1151,8 @@ let () =
11501151
bare_types)
11511152
(List.range 0 8);
11521153
add_unqualified ("dirichlet_rng", ReturnType UVector, [UVector], AoS);
1154+
add_unqualified
1155+
("dirichlet_multinomial_rng", ReturnType (UArray UInt), [UVector; UInt], AoS);
11531156
add_unqualified ("distance", ReturnType UReal, [UVector; UVector], SoA);
11541157
add_unqualified ("distance", ReturnType UReal, [URowVector; URowVector], SoA);
11551158
add_unqualified ("distance", ReturnType UReal, [UVector; URowVector], SoA);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
data {
2+
int d_int;
3+
array[d_int] int d_int_array;
4+
vector[d_int] d_vector;
5+
}
6+
transformed data {
7+
real transformed_data_real;
8+
transformed_data_real = dirichlet_multinomial_lpmf(d_int_array | d_vector);
9+
}
10+
parameters {
11+
vector[d_int] p_vector;
12+
real y_p;
13+
}
14+
transformed parameters {
15+
real transformed_param_real;
16+
transformed_param_real = dirichlet_multinomial_lpmf(d_int_array | d_vector);
17+
transformed_param_real = dirichlet_multinomial_lpmf(d_int_array | p_vector);
18+
}
19+
model {
20+
y_p ~ normal(0, 1);
21+
}

test/integration/good/function-signatures/distributions/rngs.stan

+1
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ generated quantities {
324324
n = categorical_logit_rng(theta);
325325
ns = multinomial_rng(theta, 20);
326326
ns = multinomial_logit_rng(theta, 20);
327+
ns = dirichlet_multinomial_rng(alpha, 20);
327328
x = chi_square_rng(alpha);
328329
x = chi_square_rng(nu);
329330
x = chi_square_rng(ns);

test/integration/signatures/stan_math_distributions.t

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Display all Stan math distributions exposed in the language
1515
cauchy: lpdf, rng, ccdf, cdf, log (deprecated)
1616
chi_square: lpdf, rng, ccdf, cdf, log (deprecated)
1717
dirichlet: lpdf, log (deprecated)
18+
dirichlet_multinomial: lpmf
1819
discrete_range: lpmf, rng, ccdf, cdf, log (deprecated)
1920
double_exponential: lpdf, rng, ccdf, cdf, log (deprecated)
2021
exp_mod_normal: lpdf, rng, ccdf, cdf, log (deprecated)

test/integration/signatures/stan_math_signatures.t

+2
Original file line numberDiff line numberDiff line change
@@ -4254,6 +4254,8 @@ Display all Stan math signatures exposed in the language
42544254
dirichlet_lpdf(array[] row_vector, row_vector) => real
42554255
dirichlet_lpdf(array[] row_vector, array[] vector) => real
42564256
dirichlet_lpdf(array[] row_vector, array[] row_vector) => real
4257+
dirichlet_multinomial_lpmf(array[] int, vector) => real
4258+
dirichlet_multinomial_rng(vector, int) => array[] int
42574259
dirichlet_rng(vector) => vector
42584260
discrete_range_ccdf_log(int, int, int) => real
42594261
discrete_range_ccdf_log(int, int, array[] int) => real

0 commit comments

Comments
 (0)