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

Question about Komirand seeds #11

Open
scottchiefbaker opened this issue Jan 18, 2025 · 1 comment
Open

Question about Komirand seeds #11

scottchiefbaker opened this issue Jan 18, 2025 · 1 comment

Comments

@scottchiefbaker
Copy link

In your Komirand examples in the README you set both seeds to the same number in all the examples:

komirand Seed1/Seed2 = 0x0000000000000000:
komirand Seed1/Seed2 = 0x0123456789abcdef:
komirand Seed1/Seed2 = 0x0000000000000100:

and in the code you mention: "Seed2, a supporting variable. Best initialized to the same value as Seed1". I'm curious why you recommend setting both seeds to the same number (effectively one seed). From my testing it appears that having two different seeds shortens the amount of warmup needed?

I've had pretty good luck using komihash as a source for seeds:

int main(int argc, char *argv[]) {
    const char *buf = "Some string";
    uint64_t seed1  = komihash(buf, sizeof(buf), 0);
    uint64_t seed2  = komihash(buf, sizeof(buf), seed1);

    for (int i = 0; i < 5; i++) {
        uint64_t rand64 = komirand(&seed1, &seed2);
        printf("Komirand: %llu\n", rand64);
    }
}

Is there something intrinsic to komirand that makes using the same value for both seeds preferable?

@avaneev
Copy link
Owner

avaneev commented Jan 18, 2025

This isn't a necessity, just easier to initialize, yes warm-up should be shorter as independent seed1,2 values are already uniformly random. Warm-up is needed to "randomize" the state appropriately.

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