Skip to content
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

Merged
merged 15 commits into from
Apr 8, 2020

Conversation

sbenthall
Copy link
Contributor

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 attributes pmf and X.

This should be familiar enough to the current users of HARK.
The principle benefit of this is that it:

  • begins to compartmentalize this functionality
  • makes the code a little easier to understand because one type is used unambiguously for distributions, instead of a generic type (list of arrays).

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:

  • build a mixture of Guassian representation
  • eventually swap in Dolo, which would allow smoother generation of discrete distributions from continuous ones.

@sbenthall sbenthall added this to the 1.0.0 milestone Apr 5, 2020
X = np.exp(mu)*np.ones(N)
return DiscreteDistribution(pmf, X)

@memoize
Copy link
Member

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)

Copy link
Contributor Author

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.

@mnwhite
Copy link
Contributor

mnwhite commented Apr 6, 2020 via email

@sbenthall
Copy link
Contributor Author

Please merge #616 before this PR
It is expected that the new test there will fail, since ConsRepAgentModel has not yet been included in this refactor

@sbenthall
Copy link
Contributor Author

I believe this is now ready to merge

Copy link
Collaborator

@llorracc llorracc left a 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.

@sbenthall
Copy link
Contributor Author

junk is removed in latest commit.

The issue you refer to is #227 I think

@sbenthall sbenthall merged commit f5784d5 into econ-ark:master Apr 8, 2020
@llorracc
Copy link
Collaborator

llorracc commented Apr 8, 2020

Yes, #227 is right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants