close all
x=(-3:0.0001:3)';
left=0;
right=2;
mu=0.5;
sigma=1;
x(find(x<left,1,'last'))=NaN;
x(find(x>left,1,'first'))=NaN;
x(find(x<right,1,'last'))=NaN;
x(find(x>right,1,'first'))=NaN;
y=tobitpdf(x,mu,sigma,left,right);
plot(x,y,'LineWidth',2)
hold('on')
stem(left,y(x==left),'Color','b')
stem(right,y(x==right),'Color','b')
title(['Tobit density when \mu=' num2str(mu) ', \sigma=' num2str(sigma) ', ' ...
'left=' num2str(left) ', right=' num2str(right)])
text(left,tobitpdf(left,mu,sigma,left,right)-0.01, ...
'Pr(Tobit(\mu,\sigma^2,left,right)=left)=\Phi(left,\mu, \sigma^2) ','HorizontalAlignment','right')
text(right,tobitpdf(right,mu,sigma,left,right)+0.01, ...
' Pr(Tobit(\mu,\sigma^2,left,right)=right)=1-\Phi(right, \mu, \sigma^2)','HorizontalAlignment','left')
ylim([0 1])