The efficient frontier maps the best attainable trade-offs between expected return and risk. Each point offers the highest expected return for its volatility, or the lowest volatility for its return. section 2.3
A risk–reward plot begins with simulated portfolios. Given asset expected returns μ, covariance matrix Σ, and weights w, calculate portfolio return as μₚ = wᵀμ and volatility as σₚ = √(wᵀΣw). section 2.3
From random portfolios to the frontier
Simulate 1,000 portfolios, compute each portfolio’s return and volatility, and plot the results. Then overlay the minimum-variance frontier. Its upper branch is efficient; its lower branch is inefficient because another portfolio provides the same volatility with a higher expected return. section 2.3
Without a risk-free asset, the frontier follows a hyperbola in mean–standard-deviation space. The lowest point is the global minimum-variance portfolio; the efficient frontier begins above it. For A = 1ᵀΣ⁻¹1, B = 1ᵀΣ⁻¹μ, and C = μᵀΣ⁻¹μ, its volatility satisfies σₚ = √((Aμₚ² − 2Bμₚ + C)/(AC − B²)). section 2.7
Listing 2.8 Adding minimum-variance frontier to risk–reward plot
def plot_min_var_frontier(mu, Cov): #1
A,B,C = compute_ABC(mu, Cov)
y = np.linspace(0,B/A,100) #2
x = np.sqrt((A*y*y-2*B*y+C)/(A*C-B*B)) #2
plt.plot(x,y, color='black', lw=2.5, linestyle='--') #2
y = np.linspace(B/A,.45,100) #3
x = np.sqrt((A*y*y-2*B*y+C)/(A*C-B*B)) #3
plt.plot(x,y, color='black', lw=2.5, label='Efficient Frontier') #3
plt.legend()
def compute_ABC(mu, Cov): #4
Cov_inv = np.linalg.inv(Cov)
ones = np.ones(n_assets)
A = ones @ Cov_inv @ ones
B = ones @ Cov_inv @ mu
C = mu @ Cov_inv @ mu
return A,B,C
plot_points(mu, sigma, stocks)
plot_random_portfolios(mu, Cov, n_simulations)
plot_min_var_frontier(mu, Cov)
plt.show()
Inspect the NumPy and Matplotlib implementation that computes A, B, and C, plots random portfolios, and separates the efficient branch from the inefficient branch. section 2.3
A constrained frontier turns the curve into investable portfolio choices. Sweep across target volatility levels and optimize expected return subject to long-only, full-investment, diversification, and asset-group constraints. Some targets may be infeasible. section 10.3.3

