-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LakeModel] Simplify computation of the steady state #355
Conversation
error = np.max(np.abs(new_x - x)) | ||
x = new_x | ||
x = np.array([self.A_hat[0, 1], self.A_hat[1, 0]]) | ||
x /= x.sum() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest
x /= x.sum()
return x
to
return x / x.sum()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The former is in principle strictly better: x / x.sum()
creates an intermediate array while x /= x.sum()
is an in-place operation. (Of course, the difference is negligible for this size of the data.)
I quickly reviewed this change and issue #169 , which makes the most of the analytical solution of the stationary distribution of the Markov chain when the stochastic matrix is positive. For example, let the stochastic matrix be if It is a smart change, but the thing is that it cannot handle the case when I suggest that we turn this change or the original one into an exercise. |
@shlff Good point. The proposed code does not work if |
Thanks for clarifying it @oyamad . Sorry for my late reply. I reckon there are two benefits of mentioning the extreme case (that is, One is that we can treat the case as a limiting reference point for our analysis of varying values of Additionally, mentioning this case enhances the audience's understanding of how we can apply the improved method, when it will fail, and how we can resolve the issue when it fails. |
@shlff Thanks, but I am afraid I could not see your point. The arguments in that lecture all rely on the assumptions of irreducibility ( The formula Could you elaborate? |
The following part of the lecture lecture-python.myst/lectures/lake_model.md Lines 1011 to 1025 in a4d4aaa
Also, consider using inheritance for the class. |
Execution issue is due to: https://github.com/orgs/QuantEcon/discussions/108 |
I need to fix #359 to fix the build |
@shlff would you mind to have a final review of this PR? Is anything outstanding? Preview builds will not run as the source change is from an external fork. |
Thanks @mmcky . I will check this PR and get back to you by Friday 15th. |
Thanks @mmcky . After thoroughly thinking of the simplified approach and related lectures, we should adopt this change.
lecture-python.myst/lectures/lake_model.md Lines 1011 to 1025 in a4d4aaa
Looking forward to your comments. |
Thanks @shlff , please go ahead. |
I am afraid I did not understand this argument:
The code comes from the formula "inflow = outflow" at a steady state: The reference should be to "25.6. Stationary Distributions" instead. |
I agree with @oyamad . |
Thanks @oyamad . I am sorry that's a typo. Actually, I refer it to 69.4. Dynamics of an Individual Worker, where there is a discussion on stationary distribution. |
@mmcky , would you mind to fix the build? |
@jstac this build cannot be fixed as it is originating from a fork (GitHub doesn't want to give out our EC2 credentials -- which is actually nice of them :-)) but it is a pain. I haven't been able to think of a good technical solution to this problem yet. It's only an issue for lectures that make use of I will make a replicate of the PR on a local branch so you can preview. |
Co-authored-by: Daisuke Oyama <[email protected]>
Co-authored-by: Daisuke Oyama <[email protected]>
@shlff Sorry you are right! So the formula "inflow = outflow" here is: |
Thanks @oyamad @mmcky @shlff .
@mmcky I'll step out of this now so please merge once these changes are made and you are happy (or request someone else to review). |
Latest preview is built: https://65822781c6711a007b89db11--nostalgic-wright-5fa355.netlify.app/lake_model.htm |
Thanks @mmcky . I found the steady state rate has already been defined in the texts below the code: lecture-python.myst/lectures/lake_model.md Lines 374 to 380 in e585437
I suggest we either leave it as it is or shift it up to the end of lecture-python.myst/lectures/lake_model.md Lines 198 to 208 in e585437
|
Co-authored-by: mmcky <[email protected]>
Compute the steady state by the straightforward formula for a 2x2 Markov chain instead of iteration.
See also: #169.