Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Use std::uniform (boost seems to freeze & it is the 1 dist consistant)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Apr 19, 2024
1 parent fc14bd7 commit 5d6df36
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/rxthreefry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ using namespace arma;
#include "../inst/include/rxode2random_fillVec.h"

#include <boost/random/normal_distribution.hpp>
#include <boost/random/uniform_real_distribution.hpp>
#include <boost/random/negative_binomial_distribution.hpp>
#include <boost/random/binomial_distribution.hpp>
#include <boost/random/cauchy_distribution.hpp>
Expand Down Expand Up @@ -237,7 +236,7 @@ double ntail(double l, double u, sitmo::threefry& eng){
// l and u are column vectors;
// uses acceptance-rejection from Rayleigh distr;
// method due to Marsaglia (1964);
boost::random::uniform_real_distribution<> unif(0.0, 1.0);
std::uniform_real_distribution<> unif(0.0, 1.0);
double c=l*l/2.0;
double f = expm1(c-u*u/2.0);
double x =0.0;
Expand All @@ -264,7 +263,7 @@ double tn(double l, double u, sitmo::threefry& eng, double tol = 2.05){
// # threshold can be tuned for maximum speed for each platform
// case: abs(u-l)>tol, uses accept-reject from randn
boost::random::normal_distribution<> rnorm(0.0, 1.0);
boost::random::uniform_real_distribution<> runif(0.0, 1.0);
std::uniform_real_distribution<> runif(0.0, 1.0);
double x=0;
if (fabs(u - l) > tol){
x = rnorm(eng);
Expand Down Expand Up @@ -352,7 +351,7 @@ rx_mvnrnd mvnrnd(int n, arma::mat& L, arma::vec& l,
arma::mat Z(d, n, arma::fill::zeros); // create array for variables
arma::vec p(n, arma::fill::zeros);
arma::vec uu(n, arma::fill::zeros);
boost::random::uniform_real_distribution<> unif(0.0, 1.0);
std::uniform_real_distribution<> unif(0.0, 1.0);
for (int k = 0; k < d; ++k){
//# compute matrix multiplication L*Z
arma::vec col=trans(L(k,arma::span(0,k)) * Z.rows(0, k));
Expand Down Expand Up @@ -1409,7 +1408,7 @@ extern "C" double rxunif(rx_solving_options_ind* ind, double low, double hi){

extern "C" double riunif(rx_solving_options_ind* ind, int id, double low, double hi){
if (ind->isIni == 1) {
boost::random::uniform_real_distribution<double> d(low, hi);
std::uniform_real_distribution<double> d(low, hi);
ind->simIni[id] = d(_eng[rx_get_thread(op_global.cores)]);
}
return ind->simIni[id];
Expand All @@ -1419,7 +1418,7 @@ extern "C" double riunif(rx_solving_options_ind* ind, int id, double low, double
NumericVector rxunif_(double low, double hi, int n, int ncores){
NumericVector ret(n);
int n2 = ret.size();
boost::random::uniform_real_distribution<double> d(low, hi);
std::uniform_real_distribution<double> d(low, hi);
double *retD = ret.begin();

#ifdef _OPENMP
Expand Down Expand Up @@ -1811,7 +1810,7 @@ NumericVector rpp_(SEXP nS, SEXP lambdaS, SEXP gammaS, SEXP probS, SEXP t0S, SEX
} else {
int cur = 0;
NumericVector ret(n);
boost::random::uniform_real_distribution<double> runif(0.0, 1.0);
std::uniform_real_distribution<double> runif(0.0, 1.0);
boost::random::exponential_distribution<double> rexp(lambda);
double ttest;
while (cur != n){
Expand Down

0 comments on commit 5d6df36

Please sign in to comment.