# optStrat: Obtain an Optimal Vector of Sample Sizes Given Constraint on... In elec.strat: Functions for election audits using stratified random samples

## Description

optStrat will obtain sample sizes so that, if a maximum observed overstatement of t or less is observed, the sample will produce a p-value less than alpha. The sample that optStrat obtains minimizes the total number of batches required for audit. optStrat includes options so that, given the number of samples required for audit for optimal sample sizes, the sample that minimizes the expected number of audited ballots is found.

optStrat can be a very computationally expensive function, and should only be used for small contests.

## Usage

 1 2 optStrat(Z,alpha, t, bal=TRUE, optBal=FALSE, numSamp = TRUE, asTaint = FALSE, asNumber = FALSE, M = NULL, takeOutZeroMMB=TRUE)

## Arguments

 Z A strat.elec.data object. t Value of the observed maximum, either as the MRO, as taint, or as the overstatement of the margin in votes. alpha Threshold for the p-value. If an audit does not uncover an overstatement less than t, the sample obtained will ensure that the p-value is less than alpha. bal If bal = TRUE, the output will include the expected number of audited ballots for the sample. optBal If bal = TRUE, given the number of batches required for audit in an optimal sample, optSamp will find the sample that minimizes the expected number of audited ballots. This may dramatically increase the runtime of optStrat. numSamp If numSamp = TRUE, the output will include the total number of audited batches. asTaint Set asTaint = TRUE if t is the maximum observed taint. asNumber Set asNumber if t is the maximum observed overstatement of the margin in votes. M A priori margin. If NULL, M defaults to 1. takeOutZeroMMB Setting takeOutZeroMMB = TRUE will consider batches with a maximumMarginBound of zero as having no chance of being sampled.

Mike Higgins