Comparing Sample Mean Vs Random Assortments In Python
Given df A B C Date 2010-01-17 -0.9304 3.7477 0.0000 2010-01-24 -3.6348 1.5733 -3.6348 2010-01-31 -1.8950 0.4957 -1.8950 201
Solution 1:
Well, there's a shortcut:
Since we have equal number of elements in both columns A, B. We could put them in a list and take the 10000 random samples from that list and compare them with the mean of C
sample = df['C'].values
a = df['A'].values
b = df['B'].values
population = np.concatenate((a,b), axis=0)
def mean_diff(s, p):
m = np.mean(s)
len_ = len(s)
result= np.mean([m > np.mean(npr.choice(p, len_, True))
for _ inrange(10000)])
returnresult
mean_diff(sample, population)
Post a Comment for "Comparing Sample Mean Vs Random Assortments In Python"