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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Documentation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Release Date: TBD
- Creates a `models/` directory with Python model configurations for perfect foresight and Fisher 2-period models. [1347](https://github.com/econ-ark/HARK/pull/1347)
- Fixes bug in AgentType simulations where 'who_dies' for period t was being recorded in period t-1in the history Carlo simulation functions using Python model configurations.[1296](https://github.com/econ-ark/HARK/pull/1296)
- Removes unused `simulation.py` .[1296](https://github.com/econ-ark/HARK/pull/1296)
- Fixes bug that default seed was being used in the initializing of income shock distributions. [1380](https://github.com/econ-ark/HARK/pull/1380)

### 0.13.0

Expand Down
5 changes: 5 additions & 0 deletions HARK/ConsumptionSaving/ConsIndShockModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3742,6 +3742,7 @@ def construct_lognormal_income_process_unemployment(self):
"IncUnemp": IncUnemp_list,
},
RNG=self.RNG,
seed=self.RNG.integers(0, 2**31 - 1),
)

PermShkDstn = IndexDistribution(
Expand All @@ -3751,6 +3752,8 @@ def construct_lognormal_income_process_unemployment(self):
"n_approx": PermShkCount_list,
"neutral_measure": neutral_measure_list,
},
RNG=self.RNG,
seed=self.RNG.integers(0, 2**31 - 1),
)

TranShkDstn = IndexDistribution(
Expand All @@ -3761,6 +3764,8 @@ def construct_lognormal_income_process_unemployment(self):
"IncUnemp": IncUnemp_list,
"n_approx": TranShkCount_list,
},
RNG=self.RNG,
seed=self.RNG.integers(0, 2**31 - 1),
)

return IncShkDstn, PermShkDstn, TranShkDstn
Expand Down
8 changes: 7 additions & 1 deletion HARK/ConsumptionSaving/tests/test_IndShockConsumerType.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ def test_simulated_values(self):
# simulation test -- seed/generator specific
# self.assertAlmostEqual(self.agent.state_now["aLvl"][1], 0.18438, place = HARK_PRECISION)

def test_income_dist_random_seeds(self):
a1 = IndShockConsumerType(seed=1000)
a2 = IndShockConsumerType(seed=200)

self.assertFalse(a1.PermShkDstn.seed == a2.PermShkDstn.seed)


class testBufferStock(unittest.TestCase):
"""Tests of the results of the BufferStock REMARK."""
Expand Down Expand Up @@ -414,7 +420,7 @@ def test_cyclical(self):
CyclicalExample.simulate()

self.assertAlmostEqual(
CyclicalExample.state_now["aLvl"][1], 2.41243, places=HARK_PRECISION
CyclicalExample.state_now["aLvl"][1], 3.32431, places=HARK_PRECISION
)


Expand Down
Loading