QuantEcon / lecture-source-py

Source files for "Lectures in Quantitative Economics" -- Python version
BSD 3-Clause "New" or "Revised" License
192 stars 77 forks source link

Additive functionals lecture showing a RuntimeWarning #903

Closed jstac closed 4 years ago

jstac commented 4 years ago

Search in https://python.quantecon.org/additive_functionals.html

mtiley commented 4 years ago

For anyone else interested in this issue I'm going to start breaking up the AMF_LSS_VAR class and restructuring things a bit which should as a bonus simplify debugging.

The RuntimeWarning is triggered when the plot_additive function calculates upper and lower bounds for a functional using what seems to me to be a nonsensical value for the standard deviation (0.0) of a normal distribution. The warning is given when the ppf of this distribution is taken.

Below is the relevant code from plot_additive (print statements have been added to clarify following image of output).

additive1 additive2

i.e. we have the assignment madd_dist = norm([0.], 0.0) and then madd_dist.ppf([0.01, .99]) is taken.

I have replicated the issue in a notebook here.

@shlff and I were discussing simply starting the iteration through increasing values for standard deviation at a small positive number (like 0.000000001). This gets rid of the warning.