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

Randomness consumption documentation #8

Open
meithecatte opened this issue Dec 22, 2022 · 1 comment
Open

Randomness consumption documentation #8

meithecatte opened this issue Dec 22, 2022 · 1 comment

Comments

@meithecatte
Copy link

Most functions do not document how they use their Seed internally. On one hand, these are irrelevant implementation details, but on the other hand, if they use Seed::next, the relationship between the two results might not be obvious. For example, consider:

    let seed = malachite::random::EXAMPLE_SEED;
    let low = Natural::from(1000_u32);
    let high = Natural::from(10000_u32);

    let xs = uniform_random_natural_range(seed, low.clone(), high.clone());
    let ys = uniform_random_natural_range(seed.next(), low, high);

In one conceivable implementation of uniform_random_natural_range, there exists an n such that xs.skip(n) and ys generate the same sequence. As far as I can tell from a quick test eyeball, this is not actually the case. This is of course an extreme example, other issues could be much more subtle.

Clearly, more documented guarantees around this are necessary.

@mhogrefe
Copy link
Owner

mhogrefe commented Jan 25, 2023

Sorry for the delayed response. I need to think about the best way to document this. One thing I would recommend is to use seed.fork("some-secret") rather than using Seed::next. The forked seed will almost certainly not be the same as any seed used internally by Malachite.

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

No branches or pull requests

2 participants