function [mxpar,mxlp,saverng] = probe;
%[mxpar,mxlp,saverng] = probe;  returns the vector mxpar that maximizes the log posterior likelihood. 
%It also returns mxlp, the value of the log posterior likelihood at mxpar. 
%saverng seed of the random number generator (for replicaton)
%mxpar and mxlp are  of use as a starting point for  estimation using Bayesian techniques. If priors are uniform, then mxpar 
%is  the MLE parameter estimate. The model is a latent-variable semi-structural model with transitory and permanent monetary shocks. 
%The  observables  are  Dy, Dpai, and  Dff, denoting, respectively,  output growth,  the change in the inflation rate, and the change in the  interest rate. 
%Replication materials for: ``What Do Long Data Tell Us About the Permanent Component of Inflation?''
%© Stephanie Schmitt-Grohé and Martín Uribe, May 2022. 

format compact
warning off

saverng = rng; %save  rand settings for replication 

create_structure; % creates the matrices that constitute the structure of the model.

X = 0*Y(:,1)+1; %intercept

%Lower and Upper bounds of uniform prior distributions of parameter vector
LB = PPD(:,1)-4*PPD(:,2);
UB = PPD(:,1)+4*PPD(:,2);
LB = max(LB,PPD(:,3));
UB = min(UB,PPD(:,4));

mxlp = -inf; %highest value of posteriorlikelihood

mxpar = []; %parameter vector  associated with mxlp

prior = -inf; %value prior density associated with mxpar

N = 1e6; %# of draws 

n = 0; %# of draws completed
while n<N
if mxlp == -inf
tryparam = LB+rand(np,1).*(UB-LB);
n = 0;
else
tryparam = mxpar;
aux = randi(np);
tryparam(aux) = LB(aux) + rand*(UB(aux)-LB(aux)); 
end

evaluate_structure % assigns values to the matrices of the model 

if unit_circle==1
try
likelihood =  log_like_kalman(Y,F1,Q1,Hp1',R,X,Ap');
prior = get_prior(tryparam,PPD);
catch
likelihood = -inf;
end
else
likelihood = -inf;
end

posterior  = likelihood+prior;

if posterior>mxlp
mxl = likelihood; %maximum log-lihood 
mxpar = tryparam;
mxlp = posterior; %log-posterior likelihood 

end %if logposterior>mxlp

n = n+1;
end %while n<N
