econ-ark / HARK

Heterogenous Agents Resources & toolKit
Apache License 2.0
333 stars 198 forks source link

Replace continuous distribution 'draw_' methods with dolo IID processes #611

Closed sbenthall closed 5 months ago

sbenthall commented 4 years ago

HARK currently has several functions in simulation for drawing from continuous distributions:

This is custom code that has been implemented in many other libraries. In particular, we can move towards integration with Dolo by replacing this code with calls to the 'simulate()` method in the Dolo IIDProcess class, e.g.: https://github.com/EconForge/dolo/blob/master/dolo/numeric/processes_iid.py#L114

There are some complications here:

[This is related to #519, which is about discrete distributions. Currently in HARK, continuous distributions are handled entirely separately, in simulation.py, from discrete distributions, which at the time of this writing are in utilities.py (changing with #610). Dolo IIDProcesses support discretization, so this change is instrumental to syncing up these functionalities.]

sbenthall commented 4 years ago

While doing a full replacement with dolo IIDProcesses would be major change--maybe one more appropriate for 2.0 Dolark integration, a more moderate change would be to the necessary refactoring to start mirroring Dolo.

I.e., to make a ContinuousDistribution class with a draw method, and subclass it for each particular distribution.

This sort of move would move HARK towards equivalence with Dolo, which would become apparent in the DARKolos.

llorracc commented 4 years ago

That's an excellent idea. Go for it.

sbenthall commented 4 years ago

Interesting: SymPy has stats support: https://docs.sympy.org/latest/modules/stats.html

sbenthall commented 4 years ago

Mathematica processes: https://reference.wolfram.com/language/guide/RandomProcesses.html

sbenthall commented 4 years ago

Based on @albop 's presentation, it sounds like we want to replace the HARK Distribution classes with dolo Distribution classes

sbenthall commented 3 years ago

Now there is even further lack of feature parity between HARK distributions and dolo IID processes, because of the new calcExpectations functionality #625 The closest equivalent in Dolo is 'integrate, but this does not meet all of the requirements @mnwhite put into place withcalcExpectations`

https://github.com/EconForge/dolo.py/blob/b9e7018d46e48c05bc3d54bc1dc01bc77f3f6415/dolo/numeric/distribution.py#L78

Given the time available for delivering 1.0, I will move this ticket to a later milestone. Full HARK/Dolo integration is an admirable goal, but it will be much easier to do after HARK is further refactored into elements that are similar to Dolo's.