function P=TRP_AR(grid_y,mean_y,rho,var_eps)
%Purpose:   Creates a no x no matrix of discrete conditional transition probabilities
%           assuming AR(1) process of the form
%           y(t)=mean_y+rho*y(t-1)+eps, eps ~ N(0,var_eps)

%Inputs:    %grid_y:    discrete grid
%           %mean_y:    conditional mean of the process
%           %var_eps    conditional variance of the process
%Output:    %no x no matrix of transition probabilities


no_y    =   length(grid_y);

%Calculating conditional weights
y_matr      =   repmat(grid_y',[1 no_y-1]);
mpoints_y   =   repmat((grid_y(1:no_y-1)+grid_y(2:no_y))/2,[no_y 1]);
cdf_mpoints =   normcdf(mpoints_y-rho*y_matr,mean_y*ones(no_y,no_y-1),sqrt(var_eps)*ones(no_y,no_y-1));
P           =   [cdf_mpoints(:,:) ones(no_y,1)]-[zeros(no_y,1) cdf_mpoints(:,:)];