QuantEcon / lecture-python

Source files for https://python.quantecon.org
BSD 3-Clause "New" or "Revised" License
61 stars 21 forks source link

Policy function accuracy in Cake Eating II #260

Open jms202 opened 4 years ago

jms202 commented 4 years ago

The lecture suggests that time iteration is likely to be more accurate than value function iteration.

But playing around with the solution to Exercise 2 suggests that most of the heavy lifting is done by (i) a smaller solution tolerance (1e-5 rather than 1e-4), (ii) you set x_grid_min=0.0, and (iii) the fact that you "handle small x separately" in the K() time iteration operator.

It seems that small changes in the numerical implementation can make a substantial difference to the quality of the solution. It would be great if you could address this issue directly. For example, why are (i), (ii) and (iii) above important? What is going wrong in their absence?

One other important point: when you "handle small x separately", you set the policy to consume zero. This means that you can't use the policy function to calculate the value function because log(0) = infinity. Surely there is a better solution here.

mmcky commented 3 years ago

@shlff would you mind to take a look at this.