doRNG | R package - Generic Reproducible Parallel Backend | Architecture library
kandi X-RAY | doRNG Summary
kandi X-RAY | doRNG Summary
This doRNG package provides functions to perform reproducible parallel foreach loops, using independent random streams as generated by L'Ecuyer's combined multiple-recursive generator [L'Ecuyer (1999)]. It enables to easily convert standard %dopar% loops into fully reproducible loops, independently of the number of workers, the task scheduling strategy, or the chosen parallel environment and associated foreach backend. The package doRNG is available from CRAN at The development project is hosted on GitHub at
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of doRNG
doRNG Key Features
doRNG Examples and Code Snippets
Community Discussions
Trending Discussions on doRNG
QUESTION
Recently I was learning about using mlr3 package with parallelization. As the introduction from mlr3 book (https://mlr3book.mlr-org.com/technical.html) and tutorial(https://www.youtube.com/watch?v=T43hO2o_nZw&t=1s), mlr3 uses the future backends for parallelization. I run a simple test with the following code:
...ANSWER
Answered 2021-Feb-17 at 06:56You need to set a seed with a RNG kind that supports parallelization.
QUESTION
Simulating an SIR model in R. I have a data set I am trying to plot accurately with the model. I am right now using the particle filter function, then would like to use the corresponding logLik method on the result. When I do this, I get "[1] -Inf" as a result. I can't find in the documentation why this is and how I can avoid it. Are my parameters for the model not accurate enough? Is there something else wrong?
My function looks like this: SIRsim %>% pfilter(Np=5000) -> pf logLik(pf)
From an online course lesson entitled Likelihood for POMPS https://kingaa.github.io/sbied/pfilter/ , this is the R script for the lesson. However, the code works here... I'm not sure how to reproduce my specific problem with it and unfortunately cannot share the dataset or code I am using because it is for academic research.
...ANSWER
Answered 2021-Jan-03 at 22:31If I set Beta=100
in the code above I can get a negative-infinite log-likelihood.
Replacing the measurement-error snippet with this:
QUESTION
I want to make the code below more efficient by using the foreach package. I tried it for a very long time but I don't manage to get the same result as when using the for-loops. I would like to use a nested foreach-loop including parallelization... And as output I would like to have two matrices with dim [R,b1] I would be very grateful for some suggestions!!
...ANSWER
Answered 2020-Dec-05 at 11:18I created a foreach
loop in following code. There had to be some changes made. It is a lot easier to return a list then a matrix in foreach
, since it's combined with rbind
. Especially when you want to return multiple ones. My solution here is to save everything in a list and afterwards transform it into a matrix of length 100.
Note: there is one mistake in your code. summary( mod.lm.d)$coef[2,4]
does not exist. I changed it to [2]. Adjust to your needing
QUESTION
I am parallelizing a task in R using foreach
loop with reproducible results using the dorng
operator. It is a complex code, and I have an error that I have not been able to identify even though I have run the same code with a regular for
loop.
My fundamental question is: how do I debug a function within of a foreach
loop assuming that I have reproducible results? Below is my current tentative.
In the vignette of the doRNG package, it says that a sequence of random seeds will be generated and set at the beginning of each iteration using the R number generator "L’Ecuyer-CMRG". The sequence of random seeds can be defined using set.seed
before the foreach
loop:
ANSWER
Answered 2020-Oct-13 at 09:56I think the issue comes from the fact that doRNG
gives you the random seed state and you're using that as the input of set.seed
, which requires just an integer. I expect set.seed
is only taking the first integer provided to the function to set the random seed state. Instead, what you should do is set the seed state in R. First I get the seed states and verify I can reproduce the error:
QUESTION
Anyone knows how to get all the random numbers different in the following code? E.g. with doRNG
package? I don't care about reproducibility.
Edit: Duplicates by pure chance are accepted.
...ANSWER
Answered 2020-Jul-06 at 20:31Modifying the "Hello World" example in the "getting started with doParallel" vignette to generate random numbers, I came up with:
QUESTION
I am not able to set a seed value to get reproducible results from parallelSVM()
.
ANSWER
Answered 2019-Sep-25 at 01:38In short, there is no implemented method in parallelSVM
to handle this issue. However the package uses the foreach
and doParallel
packages to handle it's parallel operations. And digging hard enough on stackoverflow a solution is possible!
Credits to this answer, on the usage of the doRNG
package, and this answer for giving me an idea for a simpler enclosed solution.
In the parallelSVM
package the parallelization happens through the parallelSVM::registerCores
functions. This function simply calls doParallel::registerDoParallel
with the number of cores, and no further arguments. My idea is simply to change the parallelSVM::registerCores
function, such that it automatically sets the seed at after creating a new cluster.
When performing parallel computation, in which you need a parallel seed, there are 2 things you need to ensure
- The seed needs to be given to each node in the cluster
- The generator needs to be one that is asymptotically random across clusters.
Luckily the doRNG
package handles the first and uses a seed that which is alright on 2. Using a combination of unlockNamespace
and assign
we can overwrite the parallelSVM::registerCores
, such that it includes a call to doRNG::registerDoRNG
with the appropriate seed (function at the end of answer). Doing this we can actually get proper reproducibility as illstrated below:
QUESTION
I have a problem with R. This function when is invoked gives me
"could not find function "%dorng%"
Am I missing some packages or what?
I have done install.packages("doRNG")
which was successfully installed.
EDIT: the same with installing rngtools
and foreach
.
ANSWER
Answered 2018-Oct-13 at 18:34install package doRNG
and attach the library:
QUESTION
Hello I am studying dorng for parallel computing. I want to see the total execution time for each k time and store into dataframe. However when I see the results stored in the list timetable, elapsed time is negative value which makes no sense to me. What is wrong with my code?
...ANSWER
Answered 2017-Nov-26 at 03:57proc.time()
is reset within clusters, so you are comparing how long your main R process has been running to how long your newly created clusters have been running, giving the negative values. It is better to use the Sys.time()
function in this situation, which compares back to the central clock. So, to count time from starting the parallel process until each cluster finishes processing:
QUESTION
What is the best way to translate the following function to parallel processing?
...ANSWER
Answered 2017-Apr-09 at 21:23The future_lapply()
function of the future package (I'm the author) provides parallel RNGs using L'Ecuyer-CMRG RNG streams, which is also what parallel::mclapply()
uses. It works the same across all OSes and regardless of parallel backend.
The following works on all OSes, including Windows:
QUESTION
I have a strange case where using foreach
with a serial and parallel backend gives different results the first time I call but then later on both results matches. I used RNG
to make the results reproducible for the same seed
Below is a sample function to explain the scenario :
...ANSWER
Answered 2017-Apr-06 at 09:40The solution is to use the following expression:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install doRNG
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page