<jupyter_start><jupyter_text>One can also try the faster version  Stochastic Simulations<jupyter_code># Shocks are discretized as a markov chain by default:
dp = model.exogenous.discretize()
sim_shock = dp.simulate(10, 100, i0=1)
for i in range(10):
    plt.plot(sim_shock[:,i,0], color='red', alpha=0.5)
sim = simulate(model, dr, i0=1, N=100)
plt.subplot(121)
for i in range(10):
    plt.plot(sim.sel(N=i,V='c'), color='red', alpha=0.5)
plt.ylabel("$c_t$")
plt.xlabel("$t$")
plt.subplot(122)
for i in range(10):
    plt.plot(sim.sel(N=i,V='w'), color='red', alpha=0.5)
plt.xlabel("$t$")
plt.ylabel("$w_t$")

plt.tight_layout()<jupyter_output><empty_output><jupyter_text>Ergodic distribution<jupyter_code>sim_long = simulate(model, dr, i0=1, N=1000, T=200)
import seaborn
seaborn.distplot(sim_long.sel(T=199, V='w'))
plt.xlabel("$w$")<jupyter_output>[33mMatplotlibDeprecationWarning[0m:/Volumes/Sync/Sys/OSX/linked/root/usr/local/bin/anaconda/lib/python3.6/site-packages/matplotlib/axes/_axes.py:6510
    
The 'normed' kwarg was deprecated in Matplotlib 2.1 and will be removed in 3.1. Use 'density' instead.<jupyter_text>Plotting Decision Rule<jupyter_code>tab = tabulate(model, dr,'w')
from matplotlib import pyplot as plt
stable_wealth = model.eval_formula('1/r+(1-1/r)*w(0)', tab)
plt.plot(tab['w'], tab['w'],color='black', linestyle='--')
plt.plot(tab['w'], stable_wealth,color='black', linestyle='--')
plt.plot(tab['w'], tab['c'])
plt.xlabel("w_t")
plt.ylabel("c_t")
plt.grid()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19273927392739273, 'fraction_numerical': 0.039603960396039604, 'mean_word_length': 6.895833333333333, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '464334', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 682, 'n_tokens_neox': 628, 'n_words': 109, 'path': 'examples/notebooks/consumption_savings.ipynb', 'repo_name': 'iworld1991/dolo', 'size': '1515'}