0

can someone please guide me to produce a plot with python like the one in this picture: confidence boxes

I am measuring the runtime of a process depending on one parameter which has 18 different values. I made 100 runs of measuring the runtime for each value. Now I need the 99%(or 95%) confidence interval as boxes around the mean for each value of the parameter.

I thought about using seaborn.tsplot() with interpolate=False and then tweaking the matplot output to produce confidence boxes like that

Here is a minimal python example of what the pandas dataFrame looks like

import pandas as pd
import numpy as np
import seaborn as sns
import scipy.stats as st

RUNS=100

X = list(range(20,210,10))

data = pd.DataFrame()
for x in X:
    fakeData = np.array([x*10]*RUNS)
    randomVariation = np.random.random(RUNS)*x
    y = np.add(fakeData, randomVariation)
    data[x] = y

#calculate mean and confidence intervals
for x in X:
    y = np.array(data[x])
    mean = np.mean(y)
    ci = st.t.interval(0.99, len(y)-1, loc=mean, scale=st.sem(y))
    print((mean,)+ ci)

EDIT: forgot to mention: I already can calculate the mean and confidence intervals. I just need some guidance to do the graphical part.

obraunsdorf
  • 61
  • 1
  • 8

0 Answers0