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

Create a uniformly distributed discrete distribution class with optimized draw method #203

Open
llorracc opened this issue Jun 25, 2020 · 2 comments

Comments

@llorracc
Copy link

Currently we don't use the uniform property so we draw from a uniform distribution in [0,1] and compare to cumulative thresholds). It's a actually a good example of a DiscreteDistribution that is not a FiniteDistribution (i.e. defined by a matrix of points and a vector of weights). Maybe naming needs to be adjusted.

(below is a condensed version of the motivation)

Suppose that our assumption for the “Process” (in your sense) is that each period there is a draw from a Normally distributed random variable.

Suppose further that we approximate that variable with the equiprobable discretization, of, say, N=100; we store the list of probability masses in a vector P of length 100.

And we want to simulate a population of size 100.

The normal way to simulate would be, for each of our 100 consumers, to pick randomly one of the 100 entries in P (with replacement).

What works much better is to pick randomly but without replacement. That is equivalent just to randomly reshuffling the order of the point-masses in the P vector.

The reason this works well is that ex ante (that is, before the arrival of period t), the expected distribution of shocks for any individual agent is identical to the distribution in the case without replacement; so with respect to the experience of any individual consumer there is no difference between with-replacement and without.

But for the population as a whole, in every period, the mean, variance, and any other statistics are guaranteed to be exactly the mean, variance, etc of the DiscretizedDistribution. That is, there’s no “sampling error” in the aggregate numbers.

@albop
Copy link
Member

albop commented Jun 25, 2020

Oups, I wanted to create a pull request for this one. Ended up pushing to master instead. Anyway the new class is implemented in this commit: 3755c8b

@llorracc
Copy link
Author

Great, thanks!

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

No branches or pull requests

2 participants