I am not entirely sure about this, but I think the PDF values are calculated wrongly. As far as I understand, we need the PDF values for w_vals, however, the current implementation calculates the PDF values for the support of the Beta-Binomial distribution. These might not coincide. I think this line should be more something like
ϕ = pdf.(BetaBinomial(n, a, b), w_vals)
ϕ ./= sum(ϕ)
The normalisation is needed, because the probability weights of the w_vals might not add to one (if they do not coincide with the support) and thus expected value calculations later on would be wrong if not normalised.
Alternatively, one could also just choose w_vals = support(BetaBinomial(n, a, b)) in which case one could replace the line with ϕ = pdf.(BetaBinomial(n, a, b), w_vals) and leave the normalisation out. The values should still be provided, since the function call without seems to be deprecated. This might even be the better option given that the expectation should be taken over the entire support of the Beta-Binomial distribution.
Again, I am not sure if I overlooked something here, so please let me know if I did.
https://github.com/QuantEcon/book-dp1/blob/eb3f5117f200a706238ad59f31b6a297e466f80c/source_code_jl/two_period_job_search.jl#L18
I am not entirely sure about this, but I think the PDF values are calculated wrongly. As far as I understand, we need the PDF values for
w_vals
, however, the current implementation calculates the PDF values for the support of the Beta-Binomial distribution. These might not coincide. I think this line should be more something likeThe normalisation is needed, because the probability weights of the
w_vals
might not add to one (if they do not coincide with the support) and thus expected value calculations later on would be wrong if not normalised.Alternatively, one could also just choose
w_vals = support(BetaBinomial(n, a, b))
in which case one could replace the line withϕ = pdf.(BetaBinomial(n, a, b), w_vals)
and leave the normalisation out. The values should still be provided, since the function call without seems to be deprecated. This might even be the better option given that the expectation should be taken over the entire support of the Beta-Binomial distribution.Again, I am not sure if I overlooked something here, so please let me know if I did.