2

I'm currently running a series of experiments, which I need to run multiple times to generate decent error bars. Each experiment outputs a file which has various info like mean/std/throughput/latency/nth percentile etc.

I then plot each of these values, but to get a more sensible result, I need to take the mean of all of these files for each cell, and plot that with the standard deviation obtained as error bars.

The code I have so far does not however work:

 data_1 = np.loadtxt(fold + "/" +  "clients_1.txt")
 data_2 = np.loadtxt(fold + "/" +  "clients_2.txt")
 data_3 = np.loadtxt(fold + "/" +  "clients_3.txt")
 data = [data_1,data_2,data_3]
 d_avg = sum(data) / float(len(data))
 err   = np.std(d_avg)
 plt.plot(d_avg[:,19],d_avg[:,7], label='Test Plot', yerr = err[:,7] )

The error I get is this:

IndexError: 0-d arrays can only use a single () or a list of newaxes (and a single ...) as an index

Slightly confused as to what the issue is. The d_agv file prints ok.

All the client files have the same number of column rows, and each cell in one file corresponds to the same cell in the other file (potentially with different values obviously)

The format of each row in each file is :

1 1 50 1 1 0 100 11.30000 9.00000 50.00000 32.09000 5.66480 9.00000 9.00000 10.00000 11.00000 12.00000 13.55000 32.85000 39.47368 

and there are multiple such rows.

4

1 回答 1

1

OK, so if I understood you well, you want the mean and the standard deviation across the runs of the experiment. If, for example, we had 2 runs with some random data given in tables down, the mean would be:

run 1   run 2       mean

1 2 3   1 3 2    1  2.5 2.5
4 5 6   5 4 6   4.5 4.5  6
7 8 9   7 8 9    7   8   9

If my assumption is correct, this is the code you want:

data_1 = np.loadtxt(fold + "/" +  "clients_1.txt")
data_2 = np.loadtxt(fold + "/" +  "clients_2.txt")
data_3 = np.loadtxt(fold + "/" +  "clients_3.txt")

data = np.array([data_1, data_2, data_3])
data_avg = data.mean(axis=0)
data_err = data.std(axis=0)
plt.plot(data_avg[:,19], data_avg[:,7], label='Test Plot')
于 2013-08-22T17:18:10.117 回答