In [4]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline

In [5]:
pop1 = np.random.binomial(10, 0.2, 10000)
pop2 = np.random.binomial(10,0.5, 10000)

In [6]:
plt.hist(pop1, alpha=0.5, label='Population 1') 
plt.hist(pop2, alpha=0.5, label='Population 2') 
plt.legend(loc='upper right') 
plt.show()



In [7]:
sample1 = np.random.choice(pop1, 100, replace=True)
sample2 = np.random.choice(pop2, 100, replace=True)

plt.hist(sample1, alpha=0.5, label='sample 1') 
plt.hist(sample2, alpha=0.5, label='sample 2') 
plt.legend(loc='upper right') 
plt.show()



In [8]:
print(sample1.mean())
print(sample2.mean())
print(sample1.std())
print(sample2.std())

diff=sample2.mean( ) -sample1.mean()
print(diff)


2.23
4.93
1.26376421852
1.85609805775
2.7

In [9]:
size = np.array([len(sample1), len(sample2)])
sd = np.array([sample1.std(), sample2.std()])
diff_se = sum(sd ** 2 / size) ** 0.5 
print(diff/diff_se)
print(size)


12.0241318579
[100 100]

In [13]:
import scipy


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-13-4dc45f4c0083> in <module>()
----> 1 import scipy

d:\users\borja.gonzalez\appdata\local\programs\python\python36-32\lib\site-packages\scipy\__init__.py in <module>()
     59 __all__ = ['test']
     60 
---> 61 from numpy._distributor_init import NUMPY_MKL  # requires numpy+mkl
     62 
     63 from numpy import show_config as show_numpy_config

ImportError: cannot import name 'NUMPY_MKL'

In [10]:
from scipy.stats import ttest_ind
print(ttest_ind(sample2, sample1, equal_var=False))


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-10-a7bf8b1fe68e> in <module>()
----> 1 from scipy.stats import ttest_ind
      2 print(ttest_ind(sample2, sample1, equal_var=False))

d:\users\borja.gonzalez\appdata\local\programs\python\python36-32\lib\site-packages\scipy\__init__.py in <module>()
     59 __all__ = ['test']
     60 
---> 61 from numpy._distributor_init import NUMPY_MKL  # requires numpy+mkl
     62 
     63 from numpy import show_config as show_numpy_config

ImportError: cannot import name 'NUMPY_MKL'

In [ ]: