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

Bugfix/2241 rng model ctor #2313

Merged
merged 21 commits into from Jun 13, 2017

Conversation

Projects
None yet
4 participants
@mitzimorris
Member

mitzimorris commented May 23, 2017

Submisison Checklist

  • Run unit tests: ./runTests.py src/test/unit
  • Run cpplint: make cpplint
  • Declare copyright holder and open-source license: see below

Summary

Stan model's 3-arg constructor takes unsigned int (RNG seed) instead of RNG object itself; change discard strategy for RNG inits accordingly.

Intended Effect

Move burden of choosing/instantiating the RNG object used by the model constructor from the interfaces to core Stan.

How to Verify

Rung unit test src/test/unit/lang/generator_test.cpp

Side Effects

The function stan/services/util/create_rng.hpp use the chain id directly as the stride (discard) instead of using (chain_id - 1). Interfaces should continue to enforce chain id > 0; the Stan model constructor calls the function create_rng using chain id 0.

Documentation

None

Reviewer Suggestions

Bob Carpenter or Sean Talts or Daniel Lee

Copyright and Licensing

Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): Mitzi Morris

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:

@mitzimorris mitzimorris referenced this pull request May 23, 2017

Merged

Bugfix/551 instantiate model with rng #552

2 of 2 tasks complete
@seantalts

minor comments, LGTM

o << INDENT2 << "boost::ecuyer1988 base_rng__ =" << EOL;
o << INDENT2 << " stan::services::util::create_rng(random_seed__, 0);"
<< EOL;
o << INDENT2 << "(void) base_rng__; // suppress unused var warning"

This comment has been minimized.

@seantalts

seantalts May 24, 2017

Member

Where does base_rng__ end up getting used, out of curiosity? Can the user refer to base_rng__ or something in their transformed data section?

@seantalts

seantalts May 24, 2017

Member

Where does base_rng__ end up getting used, out of curiosity? Can the user refer to base_rng__ or something in their transformed data section?

This comment has been minimized.

@bob-carpenter

bob-carpenter Jun 12, 2017

Contributor

The user can call _rng functions in transformed data.

@bob-carpenter

bob-carpenter Jun 12, 2017

Contributor

The user can call _rng functions in transformed data.

Show outdated Hide outdated src/stan/services/util/create_rng.hpp
Show outdated Hide outdated src/test/unit/model/finite_diff_grad_test.cpp
@bob-carpenter

This comment has been minimized.

Show comment
Hide comment
@bob-carpenter

bob-carpenter Jun 12, 2017

Contributor

I fixed the merge conflict, but this now failing here on my local tests:

test/unit/services/sample/hmc_nuts_dense_inv_metric --gtest_output="xml:test/unit/services/sample/hmc_nuts_dense_inv_metric.xml"
Running main() from gtest_main.cc
[==========] Running 4 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 4 tests from ServicesSampleHmcNutsDenseEMassMatrix
[ RUN      ] ServicesSampleHmcNutsDenseEMassMatrix.ident_no_adapt
[       OK ] ServicesSampleHmcNutsDenseEMassMatrix.ident_no_adapt (6 ms)
[ RUN      ] ServicesSampleHmcNutsDenseEMassMatrix.ident_adapt_250
src/test/unit/services/check_adaptation.hpp:63: Failure
The difference between param_vals[ij] and test::unit::stod(strs[j]) is 0.45182600000000006, which exceeds err_margin, where
param_vals[ij] evaluates to 1.2162200000000001,
test::unit::stod(strs[j]) evaluates to 0.76439400000000002, and
err_margin evaluates to 0.20000000000000001.
[  FAILED  ] ServicesSampleHmcNutsDenseEMassMatrix.ident_adapt_250 (103 ms)
[ RUN      ] ServicesSampleHmcNutsDenseEMassMatrix.use_metric_no_adapt
[       OK ] ServicesSampleHmcNutsDenseEMassMatrix.use_metric_no_adapt (1 ms)
[ RUN      ] ServicesSampleHmcNutsDenseEMassMatrix.use_metric_skip_adapt
[       OK ] ServicesSampleHmcNutsDenseEMassMatrix.use_metric_skip_adapt (1 ms)
[----------] 4 tests from ServicesSampleHmcNutsDenseEMassMatrix (111 ms total)

@mitzimorris and @betanalpha --- can you work this out?

Contributor

bob-carpenter commented Jun 12, 2017

I fixed the merge conflict, but this now failing here on my local tests:

test/unit/services/sample/hmc_nuts_dense_inv_metric --gtest_output="xml:test/unit/services/sample/hmc_nuts_dense_inv_metric.xml"
Running main() from gtest_main.cc
[==========] Running 4 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 4 tests from ServicesSampleHmcNutsDenseEMassMatrix
[ RUN      ] ServicesSampleHmcNutsDenseEMassMatrix.ident_no_adapt
[       OK ] ServicesSampleHmcNutsDenseEMassMatrix.ident_no_adapt (6 ms)
[ RUN      ] ServicesSampleHmcNutsDenseEMassMatrix.ident_adapt_250
src/test/unit/services/check_adaptation.hpp:63: Failure
The difference between param_vals[ij] and test::unit::stod(strs[j]) is 0.45182600000000006, which exceeds err_margin, where
param_vals[ij] evaluates to 1.2162200000000001,
test::unit::stod(strs[j]) evaluates to 0.76439400000000002, and
err_margin evaluates to 0.20000000000000001.
[  FAILED  ] ServicesSampleHmcNutsDenseEMassMatrix.ident_adapt_250 (103 ms)
[ RUN      ] ServicesSampleHmcNutsDenseEMassMatrix.use_metric_no_adapt
[       OK ] ServicesSampleHmcNutsDenseEMassMatrix.use_metric_no_adapt (1 ms)
[ RUN      ] ServicesSampleHmcNutsDenseEMassMatrix.use_metric_skip_adapt
[       OK ] ServicesSampleHmcNutsDenseEMassMatrix.use_metric_skip_adapt (1 ms)
[----------] 4 tests from ServicesSampleHmcNutsDenseEMassMatrix (111 ms total)

@mitzimorris and @betanalpha --- can you work this out?

@betanalpha

This comment has been minimized.

Show comment
Hide comment
@betanalpha

betanalpha Jun 12, 2017

Contributor
Contributor

betanalpha commented Jun 12, 2017

@bob-carpenter bob-carpenter merged commit 43cd41e into develop Jun 13, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
default Build finished.
Details

@bob-carpenter bob-carpenter deleted the bugfix/2241-rng-model-ctor branch Jun 13, 2017

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