A state records the environmental variables that matter for an agent’s next decision. In goals-based investing, the state is the pair (W, t): current wealth W and the current discrete time step t from 0 through T. The investor is the agent, stock and bond markets form the environment, and the state identifies the situation in which an allocation decision is made. section 6.2
Continuous wealth is converted into a finite state space so that decisions can be evaluated at defined wealth-time nodes. The wealth grid uses equally spaced points in log-wealth space. It widens over time because the range of possible wealth outcomes becomes more dispersed, producing a funnel-shaped grid rather than a rectangular one. section 6.2
Listing 6.1 Creating a state space grid for goals-based investing
import numpy as np
import matplotlib.pyplot as plt
from math import log, sqrt, exp
W0 = 1000000
T = 10
nW = 101 #1
mu_stock = 0.08
mu_bond = 0.045
sig_stock = 0.20
sig_bond = 0.0
lnW = np.zeros((nW,T+1))
W = np.zeros((nW, T+1))
for t in range(T+1):
lnW_min = log(W0) + (mu_stock-0.5*sig_stock**2)*t - 2.5*sig_stock*sqrt(t)
lnW_max = log(W0) + (mu_stock-0.5*sig_stock**2)*t + 2.5*sig_stock*sqrt(t)
lnW[:,t] = np.linspace(lnW_min, lnW_max, nW) #2
W = np.exp(lnW)
plt.figure(figsize=(10, 6)) #3
plt.subplot(1,2,1) #3
for t in range(T+1): #3
plt.scatter(t*np.ones(nW), W[:,t], color='r') #3
plt.xlabel("time, $ t $") #3
plt.ylabel("Wealth, $ W $") #3
plt.subplot(1, 2, 2) #3
for t in range(T+1): #3
plt.scatter(t*np.ones(nW), lnW[:,t], color='r') #3
plt.xlabel("time, $ t$") #3
plt.ylabel("Log of Wealth, $ \symbol{92}ln(W) $") #3
This implementation constructs a 101-point wealth grid for each of 11 time points, then plots the resulting states in wealth and log-wealth coordinates. Its bounds use initial wealth, expected stock return, stock volatility, and elapsed time. section 6.2
A discrete wealth-time state supports dynamic programming by making future outcomes computable:
- For a chosen asset allocation, transition probabilities map a current wealth state at time t to possible wealth states at time t+1. section 6.2.1
- Adjacent-state midpoints define the wealth intervals used to calculate the probability of landing in each next state. section 6.2.1
- Backward induction evaluates expected future value across actions at every wealth-time state and stores the maximizing allocation. section 6.2.1
A wealth state near a financial goal
At time t=9, a wealth node just below a $2 million goal can transition to many possible wealth nodes at t=10. For each allocation, the model estimates those probabilities, weights the terminal goal values by them, and selects the allocation with the highest expected value for that current state. section 6.2.1
The state design is also a modeling choice. Here it retains wealth and time, while the transition calculation assumes normally distributed stock returns; the distribution can be changed to accommodate alternatives such as fat tails. section 6.2.1






































