r2b2.simulation.filip_athena
¶
Athena/Minerva Simulations using Filip Zagorski’s athena library.
Module Contents¶
- class r2b2.simulation.filip_athena.FZMinervaOneRoundRisk(alpha, reported, sample_size, election_file, reported_name, db_mode=True, db_host='localhost', db_name='r2b2', db_port=27017, *args, **kwargs)¶
Bases:
r2b2.simulator.Simulation
Simulate a 1-round Minerva audit for a given sample size to compute risk limit.
- trial(self, seed)¶
Execute a 1-round minerva audit from Filip’s athena code.
- analyze(self)¶
Analyze the simulation trials.
- run(self, n: int)¶
Execute n trials of the simulation.
Executes n simulation trials by generating a random seed, running a trial with the given seed, and writing the trial entry to the trials collection.
- Parameters
n (int) – Number of trials to execute and write to database.
- get_seed(self)¶
Generate a random seed.
Note
This method generates 8 random bytes using os sources of randomness. If a different source of randomness is desired, overwrite the method per implementation.
- output(self, fd: str = None)¶
Write output of simulation to JSON file.
- Parameters
fd (str) – filename to write output to. If no file is passed, formatted JSON is simply printed.
- output_audit(self)¶
Create audit output in JSON format.
Note
This functionality is separated into a method so specific audit implementations may override it and customize their output in non-database mode.