# Comparison of means from different sample sizes

I have a data set which contains avg profit and the number of samples for each data point, no more information.

I'd like to compare the data points and decide which one to focus on more. However, I'm not sure how to take the sample size into account. As a simplified example, I have written the python code below.

import matplotlib.pyplot as plt; plt.rcdefaults()
import numpy as np

objects = ('A', 'B', 'C', 'D')
y_pos = np.arange(len(objects))
sample_sizes = [10,5,20,15]
sample_avgProfit = [12,14,2,4]
weighted_mean = 0
for i in range (len(sample_sizes)):
weighted_mean += sample_sizes[i]/sum(sample_sizes)*sample_avgProfit[i]

weighted_proportion = []
weighted_sum = sum([a*b for (a,b) in zip(sample_sizes,sample_avgProfit)])
for i in range (len(sample_sizes)):
weighted_proportion.append(sample_sizes[i]*sample_avgProfit[i]/weighted_sum)

plt.bar(y_pos, sample_avgProfit, align='center', alpha=0.5)
plt.xticks(y_pos, objects)
plt.title('avg profit')
plt.show()

plt.bar(y_pos, weighted_proportion, align='center', alpha=0.5)
plt.xticks(y_pos, objects)
plt.title('weighted proportion')
plt.show()


You'll see that B has a higher avg profit, but since its sample size is small, when I consider weighted sum and average, then A shows a higher proportion weight (BTW, is this the right term for the values I calculated?)

So my question is:

1. Am I using the right metric to compare the data points?
2. How to interpret the results? in this example, product A might have a higher weighted proportion, but still B has a higher avg price. What is the right way to make a decision in this case?