# Prior distribution in Particle Filter

Dear Prof Pfeifer，
Recently, I am studying your particle filter. In file evaluate_prior_AR1.m, there different prior distributions (beta, gamma, uniform) of parameters are considered.
Now, I have the following question:
(1) In the Uniform distribution, there is equation “priorval=priorval-log(7)”. Why we should include the term “log(7)”？ What does it mean ?
(2) If the prior distribution is Normal(-5.3,0.4) or truncated Normal disribution (0.5,0.3) . How should the evaluate_prior_AR1.m be modified?

All the Best

1. The density of a uniform distribution on [a,b] is 1/(a-b). So log density is -\log(a-b). We assumed a uniform on [-7,0] if I remember correctly, giving you the mentioned value.
2. It should be something like
``````%parameter ~ N(mu,sigma) with truncation at truncation_lower_bound and truncation_upper_bound
ii=;
if par(ii)>=truncation_lower_bound && par(ii)<truncation_upper_bound
priorval=priorval+normpdf(par(ii),mu,sigma);
else
alarm=1;
return
end
``````

where you need to fill in the respective parameter values.

1 In the file evaluate_prior_AR1.m, the prior distribution is assumed to follow Uniform(-11,-3).

%sigma_bar ~ U(-11,-3)
ii=;
if par(ii)>=(-11) && par(ii)<-3
priorval=priorval-log(7);
else
alarm=1;
return
end

Maybe, the result is -log(-8)?

I noticed the discrepancy as well and fixed the mistake online.