Skip to content

Insufficient randomness when seeding np.random #70

@JostMigenda

Description

@JostMigenda

When generating events for a flavour/channel combination, the random seed is set to args.randomseed + random.random() to ensure every combination uses a different random number seed. However, in gen_evts, since np.random.seed() must be seeded with an int, it uses int(args.randomseed + random.random()), which is simply equal to args.randomseed. In other words, all flavour/channel combinations use the same random seed for np.random, which is then used to generate a number of events per time bin.

This is usually not an issue—sntools’ randomness does not need to be cryptographically secure so re-using the same seed is okay. However, in cases where different flavours interact in a channel with the same flux and cross section (e.g., c12nc-x and c12nc-xb), this leads to both having the exact same number of events.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions