%pylab inline
from scipy import stats
rv = stats.norm(0,1)
fig,ax=subplots()
xi = np.arange(-3,3,.1)
ax.plot(xi,rv.pdf(xi),'k',lw=3.,label='$f(x)$')
xi = linspace(-3,3,20)
xi = np.arange(-3,3,.3)
xb = xi.reshape(-1,2)
xl = xb[:,0] # left edge points
ax.plot(xl,rv.pdf(xl),'ko')
width = np.diff(xl)[0]
ax.bar(xl-width/2,rv.pdf(xl),width=width,alpha=.3,color='gray')
ax.bar(-width/2,0.4,width=width,hatch='/',color='gray')
ax.set_xlabel(r'$x$',fontsize=20)
ax.set_ylabel(r'$f(x)$',fontsize=20)
ax.axis(xmin=-3,xmax=3)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['top'].axis.set_ticks_position('none')
# ax.spines['right'].axis.set_ticks_position('none')
ax.legend(fontsize=24,frameon=False)
ax.yaxis.set_visible(False)
ax.spines['left'].set_visible(False)
# fig.savefig('../fig-probability/Sampling_Monte_Carlo_000.png')
fig, ax= subplots()
fig.set_size_inches((8,8))
ax.axis((0,1,0,1))
ax.yaxis.set_visible(False)
ax.set_xlabel('$u$',fontsize=24)
ax.set_xticks(arange(0,1+1/12,1/6))
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.spines['left'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('none')
for i in range(6):
ax.text(1/6/2.+i/6,0.1/2,'%d'%(i+1),fontsize=20)
ax.set_xticklabels(['$0$']+[r'$\frac{%d}{6}$'%(i) for i in range(1,6)]+['$1$'],fontsize=20);
fig.savefig('../fig-probability/Sampling_Monte_Carlo_0001.png',bbox_inches=Bbox([[0,0],[8,3]]))
fig