Repository navigation
puremacro 5.1.0
First 5.x final release. puremacro.dp simulates panels of individual histories and reports exact inequality statistics, and it is now the stable way to declare dynamic-programming models; vfi.Model is deprecated and will be removed in 6.0. It also carries everything in the 5.0 pre-releases below: the research material is no longer part of the package (4.8.1 is the last release that contains it), puremacro.llm, and the review-defect fixes.
Added
DPSolution.simulate(n_agents, periods, seed=..., init=..., burn_in=..., record=...)simulates individual histories from apuremacro.dpsolution (discrete VFI and EGM, infinite horizon and life cycle, with or without a discrete choice and taste shocks) and returns adp.Panel. One seeded PCG64 generator draws, each period, the discrete-choice uniforms, then the shock uniforms, then the survival uniforms, so the same seed gives a bit-identical panel. Infinite-horizon panels start in the stationary distribution by default; life-cycle panels start with newborns and apply the declared survival (panel.alive).n_agents * periodsabove 5e8 raisesValueErrorwith the memory it would need. Continuous-time (HJB) and Krusell-Smith solutions raiseNotImplementedError.dp.Panel, a container for simulated histories:to_frame,to_microframe,cross_section,path, andmean,quantile,gini,top_shareandsummarypooled over periods or groupedby="t"orby="age". Dead agents keep their rows and are left out of every statistic.- Exact statistics on the solved distribution:
DPSolution.gini,top_share,quantileandlorenz. The Gini is the standard weighted Gini on the Lorenz curve,1 - sum_i w_i (L_i + L_{i-1}), the same function asMicroFrame.gini(negative values allowed, NaN when the total is not positive). In a life cycle,age=juses one cohort andage="all"returns one value per age. Krusell-Smith solutions raiseValueError(they have no stationary distribution). DPSolution.population_shares()gives each age's population share in a life cycle with survival applied.sol.distributionstill gives every cohort mass 1; the pooled statistics weight cohorts by these shares.docs/dp.md(EN/ES) has two new sections, "Panels and inequality" and "Porting from vfi.Model".dpmoves from Experimental to Stable inARCHITECTURE.md.
Fixed
vfi.simulate_panelraisesTypeErrorfor a policy that is not an integer array of grid indices. It used to cast a float policy (for example a continuous EGM policy in asset levels) withastype(np.intp), which silently truncated it to wrong indices. UseDPSolution.simulatefor such solutions.
Deprecated
vfi.Modelissues aDeprecationWarningwhen constructed and will be removed in 6.0. Declare the model withpuremacro.dp;docs/dp.md, "Porting from vfi.Model", shows the translation, and thedpversion of notebook 21's model picks the same policy on every grid node.
Changed
- The deprecated
puremacro.lp.garch_utilsmodule andpuremacro.sigma.sigma_numpy.SigmaObjectannounced removal in 5.0.0; they now name 6.0.0, together withvfi.Model, so a minor release removes nothing. - Notebook 21 (EN/ES) declares its precautionary-savings model with
puremacro.dpinstead ofvfi.Model. It now prints mean assets 6.5733 and a wealth Gini of 0.3494, the exact values of the stationary distribution. It used to print 6.6767 and 0.3924, which came from a 2000-household, 100-period simulation; that Gini was computed after subtracting the minimum asset holding, so it was not the standard Gini. The notebook adds a simulated panel whose cross-sectional Gini converges to the exact value, and its text no longer claims vectorised Bellman updates or pluggable Numba/MLX/CuPy backends.