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

generate random seeds for IndexDistribution upon creation of income d… #1380

Merged
merged 4 commits into from
Feb 7, 2024

Conversation

sbenthall
Copy link
Contributor

@sbenthall sbenthall commented Feb 7, 2024

fixes #1379 by generating random seeds from the AgentType's RNG when initializing the IndexDistributions for PermSfkDst and other distributions in construct_lognormal_income_process_unemployment

Please ensure your pull request adheres to the following guidelines:

  • Tests for new functionality/models or Tests to reproduce the bug-fix in code.
  • Updated documentation of features that add new functionality.
  • Update CHANGELOG.md with major/minor changes.

@alanlujan91
Copy link
Member

@Mv77 no need to do anything but you might want to be aware of this and issue #1379 in case it affects anything you're working on

@sbenthall
Copy link
Contributor Author

@alanlujan91 Could I please ask for an expedited review/merge of this PR, as it is a blocker for deadline-sensitive work?

@sbenthall
Copy link
Contributor Author

The errors this PR is getting are like this:

 ImportError: cannot import name 'generated_jit' from 'numba' (/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/numba/__init__.py)

Which has to do with numba dependencies which have nothing to do with this PR.

Copy link
Member

@alanlujan91 alanlujan91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having trouble testing this locally because of numba installation errors.
The code changes look good to me, everything should be passed a seed and an RNG. But shouldn't the RNG be initialized with that seed?

seed = self.RNG.integers(0, 2**31 - 1)
RNG = self.RNG(seed) 

or something to that effect?

Anyway if this is generating better p_shk streams then it's a good fix for now.

Copy link

codecov bot commented Feb 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (638c5ca) 71.58% compared to head (834d408) 71.59%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1380   +/-   ##
=======================================
  Coverage   71.58%   71.59%           
=======================================
  Files          84       84           
  Lines       13929    13933    +4     
=======================================
+ Hits         9971     9975    +4     
  Misses       3958     3958           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sbenthall
Copy link
Contributor Author

I'm honestly quite confused by the RNG argument.
It looks like it gets clobbered when 'reset_rng()' is called on the distribution, with the seed used instead.
This is likely a legacy design and I agree it should be revisited in #1381

But the problem in this case was much dumber: it was that even with a seed set for an AgentType, a default seed (0) was being used for income distributions. This is much easier to fix.

@sbenthall sbenthall merged commit 497de72 into econ-ark:master Feb 7, 2024
7 of 21 checks passed
@llorracc
Copy link
Collaborator

llorracc commented Feb 7, 2024

Seems like there should be a way to make the seed globally available. Probably would be a good idea to tack on the seed to the filename (or record it in some other way) for any output files created. And, if it's a date seed, that would make it possible to explore the history of versions of the output files by date.

@mnwhite
Copy link
Contributor

mnwhite commented Feb 7, 2024 via email

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.

PermShk's are not random enough
4 participants