from matplotlib.numerix import *
from numarray import *
from pylab import plot, subplot, legend, axis, xlabel, ylabel, text, show
Error.setMode(all=None, overflow='warn', underflow='ignore', dividebyzero='warn', invalid='warn')

subplot(211)
for y in arange(0.1, 1.1, stride=0.1) :
    x = array([0,0,y,y,1,1])
    Px_given_y = array([0,1.0/y,1.0/y,0,0,0])
    plot(x,Px_given_y)

xlabel(r'$x_1$')
ylabel(r'$p(x_1 \ given \ 0<y<1)$')
axis([-0.1,1.1,0,12])

subplot(212)
for y in arange(1.0, 2.0, stride=0.1) :
    x = array([0,0,y-1,y-1,1,1])
    Px_given_y = array([0,0,0,1.0/(2-y),1.0/(2-y),0])
    plot(x,Px_given_y)

xlabel('$x_1$')
ylabel('$p(x_1 \ given \ 1<y<2)$')
axis([-0.1,1.1,0,12])

show()

