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

Refactor sampler seeding #2456

Merged
merged 4 commits into from
Dec 11, 2023
Merged

Refactor sampler seeding #2456

merged 4 commits into from
Dec 11, 2023

Conversation

StephenButtolph
Copy link
Contributor

Why this should be merged

  1. This removes weird switching between global RNGs and seeded RNGs.
  2. This allows users of the package to specify custom sources of RNG
  3. This reduces code

How this works

Rather than creating a sampler and then seeding it - we allow a custom source of RNG (which can already be seeded).

How this was tested

  • Existing tests verify that the proposervm windowing is deterministic and that the results are unmodified.

@StephenButtolph StephenButtolph added the cleanup Code quality improvement label Dec 10, 2023
@StephenButtolph StephenButtolph added this to the v1.10.18 milestone Dec 10, 2023
@StephenButtolph StephenButtolph self-assigned this Dec 10, 2023
Comment on lines +32 to +36
&uniformReplacer{
rng: globalRNG,
},
&uniformResample{
rng: globalRNG,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we use the NewUniform constructor here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be pretty hard to understand which concrete type we are checking for (considering both of these structs are uniform samplers).

@@ -26,29 +26,28 @@ func TestDualAlphaOptimization(t *testing.T) {
BetaVirtuous: 15,
BetaRogue: 20,
}
seed uint64 = 0
seed uint64 = 0
source = prng.NewMT19937()
Copy link
Contributor

@abi87 abi87 Dec 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: should we encapsulate this within a rand.DefaultSource getter? Admittedly it'd be another global, but maybe it'd help clients select the right source of randomness?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we really care too much about the actual randomness used... just that it is deterministic. I don't really seen the benefit in adding a helper here.

Copy link
Contributor

@abi87 abi87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a couple of nits

@StephenButtolph StephenButtolph added this pull request to the merge queue Dec 11, 2023
Merged via the queue into dev with commit d2457c5 Dec 11, 2023
16 checks passed
@StephenButtolph StephenButtolph deleted the simplify-sampling-seeding branch December 11, 2023 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code quality improvement
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants