-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
154 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Generated by using Rcpp::compileAttributes() -> do not edit by hand | ||
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 | ||
|
||
one_step <- function(n, f, f_base, random_base, c) { | ||
.Call(`_AcceptReject_one_step`, n, f, f_base, random_base, c) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file modified
BIN
-139 Bytes
(100%)
docs/articles/accept_reject_files/figure-html/unnamed-chunk-10-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+171 Bytes
(100%)
docs/articles/accept_reject_files/figure-html/unnamed-chunk-11-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.13 KB
(99%)
docs/articles/accept_reject_files/figure-html/unnamed-chunk-12-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.71 KB
(100%)
docs/articles/accept_reject_files/figure-html/unnamed-chunk-13-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+401 Bytes
(100%)
docs/articles/accept_reject_files/figure-html/unnamed-chunk-14-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+11 KB
(130%)
docs/articles/accept_reject_files/figure-html/unnamed-chunk-9-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file modified
BIN
-586 Bytes
(99%)
docs/articles/inspect_files/figure-html/unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.o | ||
*.so | ||
*.dll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// #include <RcppArmadillo.h> | ||
// | ||
// // [[Rcpp::depends(RcppArmadillo)]] | ||
// // [[Rcpp::plugins(cpp11)]] | ||
// | ||
// using namespace Rcpp; | ||
// | ||
// // [[Rcpp::export]] | ||
// arma::vec one_step(int n, Function f, Function f_base, Function random_base, double c) { | ||
// arma::vec x; | ||
// while (x.size() < n) { | ||
// arma::vec x_cand = as<arma::vec>(random_base(n)); | ||
// arma::vec u = as<arma::vec>(runif(n)); | ||
// arma::uvec accepted = find(u <= as<arma::vec>(f(wrap(x_cand))) / (c * as<arma::vec>(f_base(wrap(x_cand))))); | ||
// x = join_cols(x, x_cand.elem(accepted)); | ||
// } | ||
// return x.rows(0, n-1); | ||
// } | ||
|
||
#include <RcppArmadillo.h> | ||
|
||
// [[Rcpp::depends(RcppArmadillo)]] | ||
// [[Rcpp::plugins(cpp11)]] | ||
|
||
using namespace Rcpp; | ||
|
||
// [[Rcpp::export]] | ||
arma::vec one_step(int n, Function f, Function f_base, Function random_base, double c) { | ||
arma::vec x(n); | ||
int filled = 0; | ||
|
||
while (filled < n) { | ||
arma::vec x_cand = as<arma::vec>(random_base(n)); | ||
arma::vec fx_cand = as<arma::vec>(f(wrap(x_cand))); | ||
arma::vec u = as<arma::vec>(runif(n)); | ||
arma::uvec accepted = find(u <= fx_cand / (c * as<arma::vec>(f_base(wrap(x_cand))))); | ||
|
||
int num_accepted = accepted.n_elem; | ||
if (num_accepted > 0) { | ||
int space_left = n - filled; | ||
if (num_accepted > space_left) { | ||
num_accepted = space_left; | ||
accepted = accepted.subvec(0, space_left - 1); | ||
} | ||
|
||
x.subvec(filled, filled + num_accepted - 1) = x_cand.elem(accepted); | ||
filled += num_accepted; | ||
} | ||
} | ||
|
||
return x; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Generated by using Rcpp::compileAttributes() -> do not edit by hand | ||
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 | ||
|
||
#include <RcppArmadillo.h> | ||
#include <Rcpp.h> | ||
|
||
using namespace Rcpp; | ||
|
||
#ifdef RCPP_USE_GLOBAL_ROSTREAM | ||
Rcpp::Rostream<true>& Rcpp::Rcout = Rcpp::Rcpp_cout_get(); | ||
Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get(); | ||
#endif | ||
|
||
// one_step | ||
arma::vec one_step(int n, Function f, Function f_base, Function random_base, double c); | ||
RcppExport SEXP _AcceptReject_one_step(SEXP nSEXP, SEXP fSEXP, SEXP f_baseSEXP, SEXP random_baseSEXP, SEXP cSEXP) { | ||
BEGIN_RCPP | ||
Rcpp::RObject rcpp_result_gen; | ||
Rcpp::RNGScope rcpp_rngScope_gen; | ||
Rcpp::traits::input_parameter< int >::type n(nSEXP); | ||
Rcpp::traits::input_parameter< Function >::type f(fSEXP); | ||
Rcpp::traits::input_parameter< Function >::type f_base(f_baseSEXP); | ||
Rcpp::traits::input_parameter< Function >::type random_base(random_baseSEXP); | ||
Rcpp::traits::input_parameter< double >::type c(cSEXP); | ||
rcpp_result_gen = Rcpp::wrap(one_step(n, f, f_base, random_base, c)); | ||
return rcpp_result_gen; | ||
END_RCPP | ||
} | ||
|
||
static const R_CallMethodDef CallEntries[] = { | ||
{"_AcceptReject_one_step", (DL_FUNC) &_AcceptReject_one_step, 5}, | ||
{NULL, NULL, 0} | ||
}; | ||
|
||
RcppExport void R_init_AcceptReject(DllInfo *dll) { | ||
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); | ||
R_useDynamicSymbols(dll, FALSE); | ||
} |
Oops, something went wrong.