semvec/pypi-packages huggingface dataset:
rilacs 1.0.3
Risk limiting audits via confidence sequences
License: BSD 3-Clause

# RiLACS

This package implements the martingales and confidence sequences from ["RiLACS: Risk-limiting audits via confidence sequences"](https://arxiv.org/pdf/2107.11323.pdf) and contains code for reproducing all of the plots therein.

## Installation

We currently support Python 3.7--3.10 on macOS (Intel/x86_64 and Apple Silicon) and Linux (x86_64).

```zsh
pip install rilacs
```

Installation on other platforms may still be possible, but in that case, the dependency [confseq](github.com/gostevehoward/confseq) would need to be installed manually. If you would like to see an additional platform supported, please open an [issue at confseq](https://github.com/gostevehoward/confseq/issues), not RiLACS.

## Compute a confidence sequence

```python
import numpy as np
from rilacs.confseqs import sqKelly

# Create some data
x = np.random.binomial(1, 0.5, 1000)

# Compute the confidence sequence
l, u = sqKelly(x, N = 1000)
```

## Run unit tests
```zsh
# Clone the repository 
git clone https://github.com/WannabeSmith/RiLACS.git

# Run unit tests via pytest
pytest RiLACS
```

## Reproduce the paper's plots

To generate all plots, we've created a shell script at `RiLACS/paper_plots/generate_plots.sh`:

```zsh
# Enter the plots directory
cd RiLACS/paper_plots

# Execute the script with your shell, e.g.:
zsh generate_plots.sh
```

Alternatively, you can produce each plot one-by-one:

```zsh
python RiLACS/paper_plots/distKelly_distributions/distributions.py
python RiLACS/paper_plots/relationship_to_testing/cs_testing_plots.py
# and so on.
```

## App to audit Canada's 2019 federal election

The `canada_audit` folder contains code to produce a web application which allows for interactive auditing of Canadian ridings in the 2019 federal election.

For more details, view the README in [`canada_audit`](./canada_audit)

![audit](https://ian.waudbysmith.com/audit_demo_quick.gif)

## Contributing

If you find a bug, please [open an issue](https://github.com/wannabesmith/RiLACS/issues) and we'll try to fix it as soon as possible.

## Citing

The algorithms in this codebase are based on "RiLACS: Risk-limiting audits via confidence sequences" by Ian Waudby-Smith, Philip B. Stark, and Aaditya Ramdas. The BibTeX entry is provided here.

@inproceedings{waudby2021rilacs,
  title={RiLACS: Risk Limiting Audits via Confidence Sequences},
  author={Waudby-Smith, Ian and Stark, Philip B and Ramdas, Aaditya},
  booktitle={International Joint Conference on Electronic Voting},
  pages={124--139},
  year={2021},
  organization={Springer}
}
nprr 0.1.4
Nonparametric randomized response and locally private confidence sets
License: BSD 3-Clause

# NPRR: Nonparametric randomized response

This code implements the nonparametric randomized response (NPRR) mechanism as well as methods for computing locally differentially private confidence intervals and sequences from NPRR's output. The methods are based on the paper ["A nonparametric extension of randomized response for private confidence sets"](https://arxiv.org/abs/2202.08728) by Ian Waudby-Smith, Zhiwei Steven Wu, and Aaditya Ramdas (2023).

## Installation

```sh
pip install nprr
```

## Organization

The package is organized into two main submodules:

- `nprr.mechanisms` implements privacy mechanisms including the NPRR and Laplace mechanisms along with utilities for working with them.
- `nprr.dpcs` implements the confidence intervals and sequences from the paper as well as utilities for working with them.
  
In addition, the package contains the following submodules:

- `nprr.cgf` implements some cumulant generating functions (CGF) and CGF-like functions that are used throughout the `nprr.dpcs` module.
- `nprr.plotting` implements functions for producing the plots found in the paper.
- `nprr.types` implements some basic type aliases used throughout the package.

## Reproducing the plots from the paper

Please begin the following steps from the root of the nprr directory.

1. Create and activate a virtual environment using the method of your choice. We used venv, e.g.

```sh
python3.9 -m venv venv_dpconc

source venv_dpconc/bin/activate
```

2. Install the package and its dependencies.

```sh
python install -e ./
```

3. Enter the plots directory.

```sh
cd plots
```

4. Generate figures.

```sh
### Figure 1 ###
python hoeffding_eps.py
# -> output file: bounded_beta_1_1_hoeffding_eps.pdf

### Figure 3 ###
python hoeffding_tightness_max.py
# -> output file: bounded_beta_50_50_tightness_max.pdf

### Figure 4 ###
python confint_bounded.py
# -> output file: bounded_beta_50_50_ci.pdf

### Figure 5 ###
python confseq_bounded.py
# -> output file: bounded_beta_50_50_cs.pdf

### Figure 6 ###
python two-sided-running-mean.py
# -> output file: wavy_cs.pdf

### Figure 7 ###
python ab-test.py
# -> output file: wavy_ipw_cs.pdf
```