diff --git a/Documentation/CHANGELOG.md b/Documentation/CHANGELOG.md index d91d204f1..5c81a876f 100644 --- a/Documentation/CHANGELOG.md +++ b/Documentation/CHANGELOG.md @@ -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 diff --git a/HARK/ConsumptionSaving/ConsIndShockModel.py b/HARK/ConsumptionSaving/ConsIndShockModel.py index 693089d5b..1d80b1362 100644 --- a/HARK/ConsumptionSaving/ConsIndShockModel.py +++ b/HARK/ConsumptionSaving/ConsIndShockModel.py @@ -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( @@ -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( @@ -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 diff --git a/HARK/ConsumptionSaving/tests/test_IndShockConsumerType.py b/HARK/ConsumptionSaving/tests/test_IndShockConsumerType.py index f1881a275..45a202259 100644 --- a/HARK/ConsumptionSaving/tests/test_IndShockConsumerType.py +++ b/HARK/ConsumptionSaving/tests/test_IndShockConsumerType.py @@ -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.""" @@ -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 )