From bb80ffda6f890e3396347aa5d6034aa9dcf8dcd5 Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Mon, 18 Nov 2024 16:48:41 -0500 Subject: [PATCH] Expose BNB rng --- src/middle/Stan_math_signatures.ml | 2 +- .../distributions/rngs.stan | 72 ++++++ .../signatures/stan_math_distributions.t | 2 +- .../signatures/stan_math_signatures.t | 216 ++++++++++++++++++ 4 files changed, 290 insertions(+), 2 deletions(-) diff --git a/src/middle/Stan_math_signatures.ml b/src/middle/Stan_math_signatures.ml index 05f191622..8ded9e222 100644 --- a/src/middle/Stan_math_signatures.ml +++ b/src/middle/Stan_math_signatures.ml @@ -212,7 +212,7 @@ let full_lpmf = [Lpmf; Rng; Ccdf; Cdf] let distributions = [ (full_lpmf, "beta_binomial", [DVInt; DVInt; DVReal; DVReal], Mem_pattern.SoA) - ; ( [Lpmf; Ccdf; Cdf] + ; ( [Lpmf; Ccdf; Cdf; Rng] , "beta_neg_binomial" , [DVInt; DVReal; DVReal; DVReal] , SoA ); (full_lpdf, "beta", [DVReal; DVReal; DVReal], SoA) diff --git a/test/integration/good/function-signatures/distributions/rngs.stan b/test/integration/good/function-signatures/distributions/rngs.stan index 6d3b4ec14..664fe3712 100644 --- a/test/integration/good/function-signatures/distributions/rngs.stan +++ b/test/integration/good/function-signatures/distributions/rngs.stan @@ -300,6 +300,78 @@ generated quantities { N = beta_binomial_rng(3, 3.5, u); n = beta_binomial_rng(3, 3.5, 3); n = beta_binomial_rng(3, 3.5, 3.5); + N = beta_neg_binomial_rng(ns, alpha, alpha); + N = beta_neg_binomial_rng(ns, alpha, nu); + N = beta_neg_binomial_rng(ns, alpha, ns); + N = beta_neg_binomial_rng(ns, alpha, u); + N = beta_neg_binomial_rng(ns, alpha, 3); + N = beta_neg_binomial_rng(ns, alpha, 3.5); + N = beta_neg_binomial_rng(ns, nu, alpha); + N = beta_neg_binomial_rng(ns, nu, nu); + N = beta_neg_binomial_rng(ns, nu, ns); + N = beta_neg_binomial_rng(ns, nu, u); + N = beta_neg_binomial_rng(ns, nu, 3); + N = beta_neg_binomial_rng(ns, nu, 3.5); + N = beta_neg_binomial_rng(ns, ns, alpha); + N = beta_neg_binomial_rng(ns, ns, nu); + N = beta_neg_binomial_rng(ns, ns, ns); + N = beta_neg_binomial_rng(ns, ns, u); + N = beta_neg_binomial_rng(ns, ns, 3); + N = beta_neg_binomial_rng(ns, ns, 3.5); + N = beta_neg_binomial_rng(ns, u, alpha); + N = beta_neg_binomial_rng(ns, u, nu); + N = beta_neg_binomial_rng(ns, u, ns); + N = beta_neg_binomial_rng(ns, u, u); + N = beta_neg_binomial_rng(ns, u, 3); + N = beta_neg_binomial_rng(ns, u, 3.5); + N = beta_neg_binomial_rng(ns, 3, alpha); + N = beta_neg_binomial_rng(ns, 3, nu); + N = beta_neg_binomial_rng(ns, 3, ns); + N = beta_neg_binomial_rng(ns, 3, u); + N = beta_neg_binomial_rng(ns, 3, 3); + N = beta_neg_binomial_rng(ns, 3, 3.5); + N = beta_neg_binomial_rng(ns, 3.5, alpha); + N = beta_neg_binomial_rng(ns, 3.5, nu); + N = beta_neg_binomial_rng(ns, 3.5, ns); + N = beta_neg_binomial_rng(ns, 3.5, u); + N = beta_neg_binomial_rng(ns, 3.5, 3); + N = beta_neg_binomial_rng(ns, 3.5, 3.5); + N = beta_neg_binomial_rng(3, alpha, alpha); + N = beta_neg_binomial_rng(3, alpha, nu); + N = beta_neg_binomial_rng(3, alpha, ns); + N = beta_neg_binomial_rng(3, alpha, u); + N = beta_neg_binomial_rng(3, alpha, 3); + N = beta_neg_binomial_rng(3, alpha, 3.5); + N = beta_neg_binomial_rng(3, nu, alpha); + N = beta_neg_binomial_rng(3, nu, nu); + N = beta_neg_binomial_rng(3, nu, ns); + N = beta_neg_binomial_rng(3, nu, u); + N = beta_neg_binomial_rng(3, nu, 3); + N = beta_neg_binomial_rng(3, nu, 3.5); + N = beta_neg_binomial_rng(3, ns, alpha); + N = beta_neg_binomial_rng(3, ns, nu); + N = beta_neg_binomial_rng(3, ns, ns); + N = beta_neg_binomial_rng(3, ns, u); + N = beta_neg_binomial_rng(3, ns, 3); + N = beta_neg_binomial_rng(3, ns, 3.5); + N = beta_neg_binomial_rng(3, u, alpha); + N = beta_neg_binomial_rng(3, u, nu); + N = beta_neg_binomial_rng(3, u, ns); + N = beta_neg_binomial_rng(3, u, u); + N = beta_neg_binomial_rng(3, u, 3); + N = beta_neg_binomial_rng(3, u, 3.5); + N = beta_neg_binomial_rng(3, 3, alpha); + N = beta_neg_binomial_rng(3, 3, nu); + N = beta_neg_binomial_rng(3, 3, ns); + N = beta_neg_binomial_rng(3, 3, u); + n = beta_neg_binomial_rng(3, 3, 3); + n = beta_neg_binomial_rng(3, 3, 3.5); + N = beta_neg_binomial_rng(3, 3.5, alpha); + N = beta_neg_binomial_rng(3, 3.5, nu); + N = beta_neg_binomial_rng(3, 3.5, ns); + N = beta_neg_binomial_rng(3, 3.5, u); + n = beta_neg_binomial_rng(3, 3.5, 3); + n = beta_neg_binomial_rng(3, 3.5, 3.5); n = hypergeometric_rng(5, 4, 9); n = ordered_logistic_rng(1.9, theta); N = bernoulli_rng(alpha); diff --git a/test/integration/signatures/stan_math_distributions.t b/test/integration/signatures/stan_math_distributions.t index bfc41cf35..69f68a72a 100644 --- a/test/integration/signatures/stan_math_distributions.t +++ b/test/integration/signatures/stan_math_distributions.t @@ -5,7 +5,7 @@ Display all Stan math distributions exposed in the language bernoulli_logit_glm: lpmf beta: lpdf, rng, ccdf, cdf beta_binomial: lpmf, rng, ccdf, cdf - beta_neg_binomial: lpmf, ccdf, cdf + beta_neg_binomial: lpmf, ccdf, cdf, rng beta_proportion: lpdf, ccdf, cdf binomial: lpmf, rng, ccdf, cdf binomial_logit: lpmf diff --git a/test/integration/signatures/stan_math_signatures.t b/test/integration/signatures/stan_math_signatures.t index 38e7e21b2..7d3e46a4f 100644 --- a/test/integration/signatures/stan_math_signatures.t +++ b/test/integration/signatures/stan_math_signatures.t @@ -2229,6 +2229,222 @@ Display all Stan math signatures exposed in the language beta_neg_binomial_lpmf(array[] int, array[] real, array[] real, vector) => real beta_neg_binomial_lpmf(array[] int, array[] real, array[] real, row_vector) => real beta_neg_binomial_lpmf(array[] int, array[] real, array[] real, array[] real) => real + beta_neg_binomial_rng(int, int, int) => int + beta_neg_binomial_rng(int, int, real) => int + beta_neg_binomial_rng(int, real, int) => int + beta_neg_binomial_rng(int, real, real) => int + beta_neg_binomial_rng(real, int, int) => int + beta_neg_binomial_rng(real, int, real) => int + beta_neg_binomial_rng(real, real, int) => int + beta_neg_binomial_rng(real, real, real) => int + beta_neg_binomial_rng(int, int, vector) => array[] int + beta_neg_binomial_rng(int, int, row_vector) => array[] int + beta_neg_binomial_rng(int, int, array[] int) => array[] int + beta_neg_binomial_rng(int, int, array[] real) => array[] int + beta_neg_binomial_rng(int, real, vector) => array[] int + beta_neg_binomial_rng(int, real, row_vector) => array[] int + beta_neg_binomial_rng(int, real, array[] int) => array[] int + beta_neg_binomial_rng(int, real, array[] real) => array[] int + beta_neg_binomial_rng(int, vector, int) => array[] int + beta_neg_binomial_rng(int, vector, real) => array[] int + beta_neg_binomial_rng(int, vector, vector) => array[] int + beta_neg_binomial_rng(int, vector, row_vector) => array[] int + beta_neg_binomial_rng(int, vector, array[] int) => array[] int + beta_neg_binomial_rng(int, vector, array[] real) => array[] int + beta_neg_binomial_rng(int, row_vector, int) => array[] int + beta_neg_binomial_rng(int, row_vector, real) => array[] int + beta_neg_binomial_rng(int, row_vector, vector) => array[] int + beta_neg_binomial_rng(int, row_vector, row_vector) => array[] int + beta_neg_binomial_rng(int, row_vector, array[] int) => array[] int + beta_neg_binomial_rng(int, row_vector, array[] real) => array[] int + beta_neg_binomial_rng(int, array[] int, int) => array[] int + beta_neg_binomial_rng(int, array[] int, real) => array[] int + beta_neg_binomial_rng(int, array[] int, vector) => array[] int + beta_neg_binomial_rng(int, array[] int, row_vector) => array[] int + beta_neg_binomial_rng(int, array[] int, array[] int) => array[] int + beta_neg_binomial_rng(int, array[] int, array[] real) => array[] int + beta_neg_binomial_rng(int, array[] real, int) => array[] int + beta_neg_binomial_rng(int, array[] real, real) => array[] int + beta_neg_binomial_rng(int, array[] real, vector) => array[] int + beta_neg_binomial_rng(int, array[] real, row_vector) => array[] int + beta_neg_binomial_rng(int, array[] real, array[] int) => array[] int + beta_neg_binomial_rng(int, array[] real, array[] real) => array[] int + beta_neg_binomial_rng(real, int, vector) => array[] int + beta_neg_binomial_rng(real, int, row_vector) => array[] int + beta_neg_binomial_rng(real, int, array[] int) => array[] int + beta_neg_binomial_rng(real, int, array[] real) => array[] int + beta_neg_binomial_rng(real, real, vector) => array[] int + beta_neg_binomial_rng(real, real, row_vector) => array[] int + beta_neg_binomial_rng(real, real, array[] int) => array[] int + beta_neg_binomial_rng(real, real, array[] real) => array[] int + beta_neg_binomial_rng(real, vector, int) => array[] int + beta_neg_binomial_rng(real, vector, real) => array[] int + beta_neg_binomial_rng(real, vector, vector) => array[] int + beta_neg_binomial_rng(real, vector, row_vector) => array[] int + beta_neg_binomial_rng(real, vector, array[] int) => array[] int + beta_neg_binomial_rng(real, vector, array[] real) => array[] int + beta_neg_binomial_rng(real, row_vector, int) => array[] int + beta_neg_binomial_rng(real, row_vector, real) => array[] int + beta_neg_binomial_rng(real, row_vector, vector) => array[] int + beta_neg_binomial_rng(real, row_vector, row_vector) => array[] int + beta_neg_binomial_rng(real, row_vector, array[] int) => array[] int + beta_neg_binomial_rng(real, row_vector, array[] real) => array[] int + beta_neg_binomial_rng(real, array[] int, int) => array[] int + beta_neg_binomial_rng(real, array[] int, real) => array[] int + beta_neg_binomial_rng(real, array[] int, vector) => array[] int + beta_neg_binomial_rng(real, array[] int, row_vector) => array[] int + beta_neg_binomial_rng(real, array[] int, array[] int) => array[] int + beta_neg_binomial_rng(real, array[] int, array[] real) => array[] int + beta_neg_binomial_rng(real, array[] real, int) => array[] int + beta_neg_binomial_rng(real, array[] real, real) => array[] int + beta_neg_binomial_rng(real, array[] real, vector) => array[] int + beta_neg_binomial_rng(real, array[] real, row_vector) => array[] int + beta_neg_binomial_rng(real, array[] real, array[] int) => array[] int + beta_neg_binomial_rng(real, array[] real, array[] real) => array[] int + beta_neg_binomial_rng(vector, int, int) => array[] int + beta_neg_binomial_rng(vector, int, real) => array[] int + beta_neg_binomial_rng(vector, int, vector) => array[] int + beta_neg_binomial_rng(vector, int, row_vector) => array[] int + beta_neg_binomial_rng(vector, int, array[] int) => array[] int + beta_neg_binomial_rng(vector, int, array[] real) => array[] int + beta_neg_binomial_rng(vector, real, int) => array[] int + beta_neg_binomial_rng(vector, real, real) => array[] int + beta_neg_binomial_rng(vector, real, vector) => array[] int + beta_neg_binomial_rng(vector, real, row_vector) => array[] int + beta_neg_binomial_rng(vector, real, array[] int) => array[] int + beta_neg_binomial_rng(vector, real, array[] real) => array[] int + beta_neg_binomial_rng(vector, vector, int) => array[] int + beta_neg_binomial_rng(vector, vector, real) => array[] int + beta_neg_binomial_rng(vector, vector, vector) => array[] int + beta_neg_binomial_rng(vector, vector, row_vector) => array[] int + beta_neg_binomial_rng(vector, vector, array[] int) => array[] int + beta_neg_binomial_rng(vector, vector, array[] real) => array[] int + beta_neg_binomial_rng(vector, row_vector, int) => array[] int + beta_neg_binomial_rng(vector, row_vector, real) => array[] int + beta_neg_binomial_rng(vector, row_vector, vector) => array[] int + beta_neg_binomial_rng(vector, row_vector, row_vector) => array[] int + beta_neg_binomial_rng(vector, row_vector, array[] int) => array[] int + beta_neg_binomial_rng(vector, row_vector, array[] real) => array[] int + beta_neg_binomial_rng(vector, array[] int, int) => array[] int + beta_neg_binomial_rng(vector, array[] int, real) => array[] int + beta_neg_binomial_rng(vector, array[] int, vector) => array[] int + beta_neg_binomial_rng(vector, array[] int, row_vector) => array[] int + beta_neg_binomial_rng(vector, array[] int, array[] int) => array[] int + beta_neg_binomial_rng(vector, array[] int, array[] real) => array[] int + beta_neg_binomial_rng(vector, array[] real, int) => array[] int + beta_neg_binomial_rng(vector, array[] real, real) => array[] int + beta_neg_binomial_rng(vector, array[] real, vector) => array[] int + beta_neg_binomial_rng(vector, array[] real, row_vector) => array[] int + beta_neg_binomial_rng(vector, array[] real, array[] int) => array[] int + beta_neg_binomial_rng(vector, array[] real, array[] real) => array[] int + beta_neg_binomial_rng(row_vector, int, int) => array[] int + beta_neg_binomial_rng(row_vector, int, real) => array[] int + beta_neg_binomial_rng(row_vector, int, vector) => array[] int + beta_neg_binomial_rng(row_vector, int, row_vector) => array[] int + beta_neg_binomial_rng(row_vector, int, array[] int) => array[] int + beta_neg_binomial_rng(row_vector, int, array[] real) => array[] int + beta_neg_binomial_rng(row_vector, real, int) => array[] int + beta_neg_binomial_rng(row_vector, real, real) => array[] int + beta_neg_binomial_rng(row_vector, real, vector) => array[] int + beta_neg_binomial_rng(row_vector, real, row_vector) => array[] int + beta_neg_binomial_rng(row_vector, real, array[] int) => array[] int + beta_neg_binomial_rng(row_vector, real, array[] real) => array[] int + beta_neg_binomial_rng(row_vector, vector, int) => array[] int + beta_neg_binomial_rng(row_vector, vector, real) => array[] int + beta_neg_binomial_rng(row_vector, vector, vector) => array[] int + beta_neg_binomial_rng(row_vector, vector, row_vector) => array[] int + beta_neg_binomial_rng(row_vector, vector, array[] int) => array[] int + beta_neg_binomial_rng(row_vector, vector, array[] real) => array[] int + beta_neg_binomial_rng(row_vector, row_vector, int) => array[] int + beta_neg_binomial_rng(row_vector, row_vector, real) => array[] int + beta_neg_binomial_rng(row_vector, row_vector, vector) => array[] int + beta_neg_binomial_rng(row_vector, row_vector, row_vector) => array[] int + beta_neg_binomial_rng(row_vector, row_vector, array[] int) => array[] int + beta_neg_binomial_rng(row_vector, row_vector, array[] real) => array[] int + beta_neg_binomial_rng(row_vector, array[] int, int) => array[] int + beta_neg_binomial_rng(row_vector, array[] int, real) => array[] int + beta_neg_binomial_rng(row_vector, array[] int, vector) => array[] int + beta_neg_binomial_rng(row_vector, array[] int, row_vector) => array[] int + beta_neg_binomial_rng(row_vector, array[] int, array[] int) => array[] int + beta_neg_binomial_rng(row_vector, array[] int, array[] real) => array[] int + beta_neg_binomial_rng(row_vector, array[] real, int) => array[] int + beta_neg_binomial_rng(row_vector, array[] real, real) => array[] int + beta_neg_binomial_rng(row_vector, array[] real, vector) => array[] int + beta_neg_binomial_rng(row_vector, array[] real, row_vector) => array[] int + beta_neg_binomial_rng(row_vector, array[] real, array[] int) => array[] int + beta_neg_binomial_rng(row_vector, array[] real, array[] real) => array[] int + beta_neg_binomial_rng(array[] int, int, int) => array[] int + beta_neg_binomial_rng(array[] int, int, real) => array[] int + beta_neg_binomial_rng(array[] int, int, vector) => array[] int + beta_neg_binomial_rng(array[] int, int, row_vector) => array[] int + beta_neg_binomial_rng(array[] int, int, array[] int) => array[] int + beta_neg_binomial_rng(array[] int, int, array[] real) => array[] int + beta_neg_binomial_rng(array[] int, real, int) => array[] int + beta_neg_binomial_rng(array[] int, real, real) => array[] int + beta_neg_binomial_rng(array[] int, real, vector) => array[] int + beta_neg_binomial_rng(array[] int, real, row_vector) => array[] int + beta_neg_binomial_rng(array[] int, real, array[] int) => array[] int + beta_neg_binomial_rng(array[] int, real, array[] real) => array[] int + beta_neg_binomial_rng(array[] int, vector, int) => array[] int + beta_neg_binomial_rng(array[] int, vector, real) => array[] int + beta_neg_binomial_rng(array[] int, vector, vector) => array[] int + beta_neg_binomial_rng(array[] int, vector, row_vector) => array[] int + beta_neg_binomial_rng(array[] int, vector, array[] int) => array[] int + beta_neg_binomial_rng(array[] int, vector, array[] real) => array[] int + beta_neg_binomial_rng(array[] int, row_vector, int) => array[] int + beta_neg_binomial_rng(array[] int, row_vector, real) => array[] int + beta_neg_binomial_rng(array[] int, row_vector, vector) => array[] int + beta_neg_binomial_rng(array[] int, row_vector, row_vector) => array[] int + beta_neg_binomial_rng(array[] int, row_vector, array[] int) => array[] int + beta_neg_binomial_rng(array[] int, row_vector, array[] real) => array[] int + beta_neg_binomial_rng(array[] int, array[] int, int) => array[] int + beta_neg_binomial_rng(array[] int, array[] int, real) => array[] int + beta_neg_binomial_rng(array[] int, array[] int, vector) => array[] int + beta_neg_binomial_rng(array[] int, array[] int, row_vector) => array[] int + beta_neg_binomial_rng(array[] int, array[] int, array[] int) => array[] int + beta_neg_binomial_rng(array[] int, array[] int, array[] real) => array[] int + beta_neg_binomial_rng(array[] int, array[] real, int) => array[] int + beta_neg_binomial_rng(array[] int, array[] real, real) => array[] int + beta_neg_binomial_rng(array[] int, array[] real, vector) => array[] int + beta_neg_binomial_rng(array[] int, array[] real, row_vector) => array[] int + beta_neg_binomial_rng(array[] int, array[] real, array[] int) => array[] int + beta_neg_binomial_rng(array[] int, array[] real, array[] real) => array[] int + beta_neg_binomial_rng(array[] real, int, int) => array[] int + beta_neg_binomial_rng(array[] real, int, real) => array[] int + beta_neg_binomial_rng(array[] real, int, vector) => array[] int + beta_neg_binomial_rng(array[] real, int, row_vector) => array[] int + beta_neg_binomial_rng(array[] real, int, array[] int) => array[] int + beta_neg_binomial_rng(array[] real, int, array[] real) => array[] int + beta_neg_binomial_rng(array[] real, real, int) => array[] int + beta_neg_binomial_rng(array[] real, real, real) => array[] int + beta_neg_binomial_rng(array[] real, real, vector) => array[] int + beta_neg_binomial_rng(array[] real, real, row_vector) => array[] int + beta_neg_binomial_rng(array[] real, real, array[] int) => array[] int + beta_neg_binomial_rng(array[] real, real, array[] real) => array[] int + beta_neg_binomial_rng(array[] real, vector, int) => array[] int + beta_neg_binomial_rng(array[] real, vector, real) => array[] int + beta_neg_binomial_rng(array[] real, vector, vector) => array[] int + beta_neg_binomial_rng(array[] real, vector, row_vector) => array[] int + beta_neg_binomial_rng(array[] real, vector, array[] int) => array[] int + beta_neg_binomial_rng(array[] real, vector, array[] real) => array[] int + beta_neg_binomial_rng(array[] real, row_vector, int) => array[] int + beta_neg_binomial_rng(array[] real, row_vector, real) => array[] int + beta_neg_binomial_rng(array[] real, row_vector, vector) => array[] int + beta_neg_binomial_rng(array[] real, row_vector, row_vector) => array[] int + beta_neg_binomial_rng(array[] real, row_vector, array[] int) => array[] int + beta_neg_binomial_rng(array[] real, row_vector, array[] real) => array[] int + beta_neg_binomial_rng(array[] real, array[] int, int) => array[] int + beta_neg_binomial_rng(array[] real, array[] int, real) => array[] int + beta_neg_binomial_rng(array[] real, array[] int, vector) => array[] int + beta_neg_binomial_rng(array[] real, array[] int, row_vector) => array[] int + beta_neg_binomial_rng(array[] real, array[] int, array[] int) => array[] int + beta_neg_binomial_rng(array[] real, array[] int, array[] real) => array[] int + beta_neg_binomial_rng(array[] real, array[] real, int) => array[] int + beta_neg_binomial_rng(array[] real, array[] real, real) => array[] int + beta_neg_binomial_rng(array[] real, array[] real, vector) => array[] int + beta_neg_binomial_rng(array[] real, array[] real, row_vector) => array[] int + beta_neg_binomial_rng(array[] real, array[] real, array[] int) => array[] int + beta_neg_binomial_rng(array[] real, array[] real, array[] real) => array[] int beta_proportion_lccdf(real, real, int) => real beta_proportion_lccdf(real, real, real) => real beta_proportion_lccdf(real, real, vector) => real