Skip to content

Commit

Permalink
Build exponential mean interface
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz committed Dec 3, 2024
1 parent f42a391 commit a9c7ba3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/combine.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ monty_model_combine <- function(a, b, properties = NULL,
##'
##' @export
monty_model_split <- function(model, prior_first = FALSE) {
require_monty_model(model, arg = name, call = call)
require_monty_model(model, arg = "model", call = call)

if (!inherits(model$model$data, "_combined_model")) {
cli::cli_abort(
Expand Down
4 changes: 4 additions & 0 deletions R/cpp11.R

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/cpp11.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,21 +358,28 @@ cpp11::doubles cpp_monty_random_exponential_rate(cpp11::doubles rate, cpp11::sex
rate, "rate");
}

// exponential_rate
[[cpp11::register]]
cpp11::doubles cpp_monty_random_n_exponential_rate(size_t n_samples, cpp11::doubles rate, cpp11::sexp ptr) {
const auto fn = [](auto& state, auto rate) { return monty::random::exponential_rate<double>(state, rate); };
return monty_random_sample_n_1(fn, n_samples, ptr, "exponential_rate",
rate, "rate");
}

// exponential_mean
[[cpp11::register]]
cpp11::doubles cpp_monty_random_exponential_mean(cpp11::doubles mean, cpp11::sexp ptr) {
const auto fn = [](auto& state, auto mean) { return monty::random::exponential_mean<double>(state, mean); };
return monty_random_sample_1_1(fn, ptr, "exponential_mean",
mean, "mean");
}

[[cpp11::register]]
cpp11::doubles cpp_monty_random_n_exponential_mean(size_t n_samples, cpp11::doubles mean, cpp11::sexp ptr) {
const auto fn = [](auto& state, auto mean) { return monty::random::exponential_mean<double>(state, mean); };
return monty_random_sample_n_1(fn, n_samples, ptr, "exponential_mean",
mean, "mean");
}

// poisson
[[cpp11::register]]
cpp11::doubles cpp_monty_random_poisson(cpp11::doubles lambda, cpp11::sexp ptr) {
Expand Down

0 comments on commit a9c7ba3

Please sign in to comment.