-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
DiscreteDistribution object should store reference to continuous distribution it was approximated from #949
Comments
An implementation:
|
Note that there are many possible ways to discretize any particular continuous distribution, which will have different parameters, so we will need to keep track of the method and its parameters. For example, for a continuous distribution, you could have equiprobable, Hermite, bounded equiprobable, truncated equiprobable, bounded equiprobable, etc. |
that is exactly what is done in PR #954 |
To be clear: PR #954 assumes the Currently, we have do not have multiple discretization procedures for a single distribution type. If there was an example of an alternative discretization procedure implemented in code, it would be easier to demonstrate how this would work, and discuss alternative architectures. |
See #804 |
This was discussed at least as long ago as #121, and a number of examples were scattered through the diffuse discussions that were concentrated and distilled here. The concrete instance we should probably start with is the case of the normal (and lognormal) distributions. Two distinct choices are important:
For distributing the "tail mass" there are two common choices: ["truncation"]((https://reference.wolfram.com/language/ref/CensoredDistribution.html) and "censoring". With "censoring", all of the mass of points beyond the limit is assigned to a point AT the limit. For distributing the points inside the interval, there are many possible choices. The most popular two are Gauss-Hermite and equiprobable, but many other choices are possible. Mathematica handles all of this by having a set of predefined objects that it I'm not proposing anything remotely so fancy. Suppose I want to define the "true" model as one in which the distribution of income shocks is a censored lognormal with the censoring taking place at three standard deviations. Then we might have, say, three or four different "approximated" models:
I'm not proposing that we build a tool to which we can give all of these and many other various possibilities, and it does all the work. Instead, I'm proposing that we tell the user: "You write a function which has a set of arguments. The function, when called with those arguments, generates the discrete distribution you want. What you pass to our Solve and our Simulate routines is your function, and the specific parameter values you want it evaluated at if we get to the point where we need it. (Which we surely will unless there's a bug in the code before that point)." Dolo kind of works this way -- at least if I recall correctly the substance of a conversation with Pablo a while ago when I asked "what if the user doesn't want to use one of your standard built in discretization routines" and he said "there's a hook in the code where they can build in whatever alternative they want." |
I was unclear. I meant an example of multiple discretization procedures for the same distribution written in Python code. I would not feel comfortable, myself, implementing what you propose without being able to demonstrate its functionality with at least two such functions. Can you point to the Dolo code that does this? |
Ah , it looks like we do have code for both equiprobable and Gauss-Hermite approximations to lognormal in HARK, sort of... This starts with the parameters of the continuous distribution, and returns a discrete distribution. Line 600 in e2fe6cf
Contrast this with the current implementation of Line 98 in e2fe6cf
I think what you are proposing is that these two modes of discretization should exist as standalone functions. Maybe that's the current architecture of Have I misunderstood you? |
Took a closer look at how this is currently handled in the case of our widely used mean-one approximation to the lognormal, which is via the MeanOneLognormal class, and the approx method applied to it. At some point I'd propose we make the following changes:
As I remarked somewhere else, I very much like the architecture of how Mathematica handles this. Doing something similar may be too heavy a lift for our purposes, but it might not be so hard -- I'm really not sure. |
No underscores in class names. |
OK; you're the PEP8 jedi master. But, yes, I think the right way to think about it is that a discrete approximation is a thing that is done to a continuous distribution. And there are multiple different ways to do it, which be combined (censoring and equiprobable, censoring and hermite, truncated and hermite, etc). |
#640 (comment)
So that it can be inspected and its underlying mu, sigma, count values (for example) can be compared to new configurations.
The text was updated successfully, but these errors were encountered: