VisualDemoTransformingRVs

913 days ago by raazesh.sainudiin

Visual Demonstration of Transformations of RVs

Example 1

def g(x): return 1-x 
       
p = line([(x,0,1) for x in srange(0, 1, 1/100.)],color='red') # f_X(x) = 1, if 0 < x < 1 p += line([(x,g(x),0) for x in srange(0.0001, 1, 1/100.)],color='green') # y=g(x)=-log(x) p += line([(0,y,1) for y in srange(0, 1, 1/100.)]) # f_Y(y) p.show() 
       

Example 2

def g(x): return -log(x) 
       
p = line([(x,0,1) for x in srange(0, 1, 1/100.)],color='red') # f_X(x) = 1, if 0 < x < 1 p += line([(x,g(x),0) for x in srange(0.0001, 1, 1/100.)],color='green') # y=g(x)=-log(x) p += line([(0,y,1*exp(-1*y)) for y in srange(0, 10, 1/10.)]) # f_Y(y) p.show() 
       
#points? # uncomment and evaluate for help 
       

Example 3

def g(x): return tan(pi*(x-1/2)) 
       
line([(x,g(x)) for x in srange(0.01,0.99,0.001)]) 
       
p = line([(x,0,1) for x in srange(0, 1, 1/100.)],color='red') # f_X(x) = 1, if 0 < x < 1 p += line([(x,0,0) for x in srange(0, 1, 1/100.)],color='black') # domain of x in 0 < x < 1 p += line([(x,g(x),0) for x in srange(0.01,0.99,0.001)],color='green') # y=g(x)=-log(x) p += line([(0,y,1/(pi*(1+y^2))) for y in srange(-10, 10, 1/100.)]) # f_Y(y) p.show()