I need to report the ratio of success to failure with a confidence interval. Assume I have a list of success and failures in the following form:

$X = [1,0,0,0,0,1,1,1,1,0,0]$

I need to calculate the win to loss ratio ($wlr=\frac{p}{1-p}$) and its confidence interval.

I checked a bootstrapped distribution of it and noticed the distribution is not normal.

enter image description here

I have two questions:

  • Is there any caveat reporting 0.25-0.975 percentile as my confidence interval?
  • Do I need to report the mean or median of this distribution as my point estimate fo wlr?

Here is the code for reference:

def win_loss_ratio(seq,
    '''calcuates the odds ratio for a sequence of
    0,1 (failure, succcess).

    returns an odds ratio'''

    p = np.clip(np.mean(seq), p_min, 1 - p_min)
    odds = p / (1 - p)
    return odds

def bs_replicates(
    ''' calculates a list of bootstrap replicates for
    a sequence of success and failures and a replicate function

    returns a list of drawed replicates'''

    replicates = []
    for i in range(samples):
        bs_sample = np.random.choice(seq, size=len(seq), replace=True)
        rep = func(bs_sample)
    return replicates

def bs_confintv(
    '''calcuates a confidence interval with a provided confidence interval
    returns: average, (lower bound of confidence interval, higher bound of confidence interval)'''

    replicates = sorted(bs_replicates(seq, func, samples=samples))
    n = len(replicates)
    lower_ind = int(n * (1 - conf_level) / 2)
    upper_ind = n - lower_ind
    return (np.median(replicates), (replicates[lower_ind],

seq = 20*[0] + 200*[1]
bs_confintv(seq, win_loss_ratio)
  • $\begingroup$ If 0 losses has non-zero probability, the distribution doesn't have a mean... $\endgroup$ – Glen_b -Reinstate Monica Sep 23 '19 at 5:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.