Created
June 7, 2017 06:02
-
-
Save jmoy/a36e2399418d8bdb18e649d4b8f698db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import numpy.random as nr | |
def gen(N): | |
X = nr.choice([0,1],size=N,p=[0.6,0.4]) | |
D = nr.choice([0,1],size=N,p=[0.6,0.4]) | |
epsi = nr.uniform(0,2,N) | |
Y = X+D*epsi | |
return X,D,epsi,Y | |
def estim(D,Y): | |
Y0 = np.average(Y[D==0]) | |
Y1 = np.average(Y[D==1]) | |
return Y1-Y0 | |
X,D,epsi,Y = gen(10000) | |
estim(D,Y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment