-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
Use a python class for discrete probability distributions #610
Conversation
X = np.exp(mu)*np.ones(N) | ||
return DiscreteDistribution(pmf, X) | ||
|
||
@memoize |
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.
Any ideas why is this here?
(I know this isn't this PR change)
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.
Are you referring to the @memoize decorator?
I assumed it was for performance reasons.
Yeah. Memoize is there so that in a problem with a large T_cycle but
identical permanent or transitory shock distributions, the function doesn't
get re-computed dozens of hundreds of times.
…-- mnw
On Sun, Apr 5, 2020, 7:25 PM Sebastian Benthall ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In HARK/distribution.py
<#610 (comment)>:
> + for i in range(K):
+ zBot = cutoffs[i]
+ zTop = cutoffs[i+1]
+ tempBot = (mu+sigma**2-np.log(zBot))/(np.sqrt(2)*sigma)
+ tempTop = (mu+sigma**2-np.log(zTop))/(np.sqrt(2)*sigma)
+ if tempBot <= 4:
+ X[i] = -0.5*np.exp(mu+(sigma**2)*0.5)*(erf(tempTop) - erf(tempBot))/pmf[i]
+ else:
+ X[i] = -0.5*np.exp(mu+(sigma**2)*0.5)*(erfc(tempBot) - erfc(tempTop))/pmf[i]
+
+ else:
+ pmf = np.ones(N)/N
+ X = np.exp(mu)*np.ones(N)
+ return DiscreteDistribution(pmf, X)
+
***@***.***
Are you referring to the @memoize <https://github.com/memoize> decorator?
I assumed it was for performance reasons.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#610 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADKRAFOJ4IKZGTWOXMZ2OKDRLEHQNANCNFSM4L7ZRRKA>
.
|
Please merge #616 before this PR |
I believe this is now ready to merge |
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.
Aside from my one minor bug (the junk file that needs to be deleted), this looks great to me!
One point that should be addressed separately is that the IncomeDstn variable should really be renamed IncShkDsnt -- it is NOT the distribution of income, it is the distribution of income SHOCKS. I think there's an issue about this somewhere long ago (if not, there should be).
I do NOT think that change should be made as part of this refactor. Instead, it should be its own self-contained PR. We should at the same time construct corresponding PR's for DemARK and REMARK repos if there are any notebooks therein that directly reference IncomeDstn.
junk is removed in latest commit. The issue you refer to is #227 I think |
Yes, #227 is right |
This PR addressed issue #519
This is only a refactor of the current HARK code. It does not yet pull in any new dolo dependencies.
Rather, it refactors the discrete distribution-related code into a new module,
distribution
, containing a class,DiscreteDistribution
, with attributespmf
andX
.This should be familiar enough to the current users of HARK.
The principle benefit of this is that it:
Tests are passing locally for me.
I'd like to ask to expedite this PR because my understanding is that @llorracc is doing high-priority work on seeding models with ergodic distributions.
This change, though it touches a lot of code, is meant to be a minimal restructure to make it easier to: