QuantEcon / lecture-source-py

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

Optimal growth lecture 1 issue #937

Closed Harveyt47 closed 4 years ago

Harveyt47 commented 4 years ago

There is an error occurring in the optimal growth lecture. optgrowth I believe that this error is originating from the minimize_scalar function in scipy which is used in the maximize function in the optgrowth lecture. I also believe that the method='bounded' variable in the minimize_scalar function is causing this error.

When I remove method='bounded' from being called I get the following output optgro This output is obviously not optimal.

Harveyt47 commented 4 years ago

I believe it is a problem with the bounds. The initial bound in the maximize function is 1e-05. This is causing the error. the output below illustrates this.

Screenshot from 2020-02-25 14-13-18

changing the upper bound to 1e-04 fixes the bug.

I am unsure why the minimize_scalar function can not take bounds so close to one another.

Harveyt47 commented 4 years ago

Hi @jstac , I believe there may be a floating point error occurring within scipy function.

I think that the best fix for now is to change the minimum of the grid from 1e-5 to 1e-4.

jstac commented 4 years ago

Thanks @Harveyt47, good detective work.

Please put in a PR which fixes this issue using the technique you propose and ask someone to review it.