Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootdht parallel random number generation seed and replication #94

Closed
dill opened this issue Jun 16, 2021 · 1 comment
Closed

bootdht parallel random number generation seed and replication #94

dill opened this issue Jun 16, 2021 · 1 comment
Assignees
Milestone

Comments

@dill
Copy link
Contributor

dill commented Jun 16, 2021

As raised by @lenthomas in #44, it would be nice to set the RNG when running the bootstrap in parallel. See doRNG.

@dill dill added this to the 1.0.4 release milestone Jun 16, 2021
@dill dill self-assigned this Jun 16, 2021
@dill dill closed this as completed in 78966db Aug 11, 2021
@dill
Copy link
Contributor Author

dill commented Aug 11, 2021

doRNG added as a suggested package to deal with this issue.

library(Distance)
data("minke")
easy <- ds(data=minke, key="hr", truncation=1.5)
ex.N <- function(ests, fit) {
  return(data.frame(Label = ests$individuals$N$Label,
                    Dhat = ests$individuals$N$Estimate))
}

easyboot <- bootdht(model=easy, flatfile=minke, nboot=10, cores = 3,
                    summary_fun = ex.N)
easyboot2 <- bootdht(model=easy, flatfile=minke, nboot=10, cores = 3,
                    summary_fun = ex.N)

Yields:

> cbind(easyboot, easyboot2)
   Label      Dhat bootstrap_ID Label       Dhat bootstrap_ID
1  North 19083.401            1 North  35283.497            1
2  South  5119.951            1 South   6600.605            1
3  Total 24203.352            1 Total  41884.101            1
4  North 16208.894            2 North  24095.007            2
5  South  3509.791            2 South   5379.405            2
6  Total 19718.685            2 Total  29474.412            2
7  North 24356.201            3 North 425064.211            3
8  South  4777.667            3 South 267960.427            3
9  Total 29133.869            3 Total 693024.639            3
10 North 20646.008            4 North  37885.080            4
11 South  4584.703            4 South  11117.031            4
12 Total 25230.711            4 Total  49002.112            4
13 North 24038.870            5 North  13877.807            5
14 South  6353.078            5 South   2384.373            5
15 Total 30391.948            5 Total  16262.180            5
16 North 27844.266            6 North  10877.678            6
17 South  6658.389            6 South   4384.059            6
18 Total 34502.655            6 Total  15261.737            6
19 North 17157.443            7 North   9613.602            7
20 South  2606.327            7 South   6647.420            7
21 Total 19763.770            7 Total  16261.022            7
22 North 21095.366            8 North  16901.738            8
23 South  4268.078            8 South   4995.280            8
24 Total 25363.445            8 Total  21897.017            8
25 North 16762.802            9 North  25957.748            9
26 South  6842.953            9 South   4316.337            9
27 Total 23605.755            9 Total  30274.084            9
28 North 24327.593           10 North  23015.386           10
29 South  3457.492           10 South  15377.370           10
30 Total 27785.085           10 Total  38392.756           10

But setting seed:

set.seed(100)
easyboot <- bootdht(model=easy, flatfile=minke, nboot=10, cores = 3,
                    summary_fun = ex.N)
set.seed(100)
easyboot2 <- bootdht(model=easy, flatfile=minke, nboot=10, cores = 3,
                    summary_fun = ex.N)

Yields:

> cbind(easyboot, easyboot2)
   Label      Dhat bootstrap_ID Label      Dhat bootstrap_ID
1  North 27356.829            1 North 27356.829            1
2  South  7740.624            1 South  7740.624            1
3  Total 35097.453            1 Total 35097.453            1
4  North 20019.200            2 North 20019.200            2
5  South  8947.576            2 South  8947.576            2
6  Total 28966.776            2 Total 28966.776            2
7  North 15900.905            3 North 15900.905            3
8  South  1066.180            3 South  1066.180            3
9  Total 16967.085            3 Total 16967.085            3
10 North 30432.876            4 North 30432.876            4
11 South  7673.825            4 South  7673.825            4
12 Total 38106.701            4 Total 38106.701            4
13 North 21916.181            5 North 21916.181            5
14 South 10754.574            5 South 10754.574            5
15 Total 32670.755            5 Total 32670.755            5
16 North 12337.920            6 North 12337.920            6
17 South  6917.687            6 South  6917.687            6
18 Total 19255.608            6 Total 19255.608            6
19 North 22634.354            7 North 22634.354            7
20 South  5543.670            7 South  5543.670            7
21 Total 28178.023            7 Total 28178.023            7
22 North 30111.507            8 North 30111.507            8
23 South  7806.416            8 South  7806.416            8
24 Total 37917.923            8 Total 37917.923            8
25 North 18790.467            9 North 18790.467            9
26 South  4328.954            9 South  4328.954            9
27 Total 23119.421            9 Total 23119.421            9
28 North 16058.240           10 North 16058.240           10
29 South  5702.957           10 South  5702.957           10
30 Total 21761.197           10 Total 21761.197           10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant