Skip to content

Commit

Permalink
Merge pull request #1383 from econ-ark/master
Browse files Browse the repository at this point in the history
Merge RNG fix into v14 preparation branch
  • Loading branch information
mnwhite authored Feb 7, 2024
2 parents 4e741dc + 497de72 commit 05138ef
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
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: February 1, 2024
- 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-1 in 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

0 comments on commit 05138ef

Please sign in to comment.