Re: [Rcpp-devel] for loop and random draws

2024-10-25 Thread Dirk Eddelbuettel
On 25 October 2024 at 15:42, Denis Haine wrote: | I'm totally puzzled on why I've got these results. How can I get the same | output with Rcpp + regression as with the R loop +/- regression? I think you continue to gloss over the fact there "is a contract": we call C++ code from R, Rcpp helps, R

Re: [Rcpp-devel] for loop and random draws

2024-10-25 Thread Denis Haine
Hi, Sorry to get back to this, but I can't figure out how to solve it. Do not hesitate to direct me to another forum if this one is not appropriate. I don't think there's anything wrong with Rcpp, but I might not proceed with the loop in Rcpp the right way. So I tried various regressions i

Re: [Rcpp-devel] for loop and random draws

2024-10-01 Thread Dirk Eddelbuettel
On 1 October 2024 at 11:57, Denis Haine wrote: | But adding the regression to define_e1() (as define_e2() in previous email) | does not give the same. The first iteration in the loop is identical in both, | but not the subsequent ones. That's why I was thinking it could be linked to | the seed, b

[Rcpp-devel] for loop and random draws

2024-10-01 Thread Denis Haine
Hi, I have two different results within a for loop if a random draw is followed by an additional operation, i.e.: // [[Rcpp::export]] NumericMatrix define_e(int iter, NumericMatrix obs_mat, NumericVector draws) { Rcpp::NumericVector d = obs_mat(_, 1); Rcpp::NumericVector pr = no_init(d

Re: [Rcpp-devel] for loop and random draws

2024-10-01 Thread Denis Haine
Sorry, I missed sharing that part comparing the two functions, vector vs. matrix without the regression. // [[Rcpp::export]] NumericMatrix define_e(int iter, NumericMatrix obs_mat, NumericVector draws) { Rcpp::NumericVector d = obs_mat(_, 1); Rcpp::NumericVector pr = no_init(d.length())

Re: [Rcpp-devel] for loop and random draws

2024-10-01 Thread Dirk Eddelbuettel
On 1 October 2024 at 09:59, Dirk Eddelbuettel wrote: | This is not reproducible. You show two functions, they both take arguments, | you do not supply those. We cannot run this, so we cannot really help you. I missed the lines at the bottom past your signature, so I was wrong. My bad. I would s

Re: [Rcpp-devel] for loop and random draws

2024-10-01 Thread Dirk Eddelbuettel
Denis, This is not reproducible. You show two functions, they both take arguments, you do not supply those. We cannot run this, so we cannot really help you. Please try rephrasing this as a _self-contained_ example. Now, it is always possibly that while the RNG seeds get reset properly on 'nor