0/70 completed
Optimization Interactive

Convex Optimization

When the problem is convex, local optima are global optima. Efficient algorithms guarantee finding the best solution.

๐Ÿ“Š What is Convex?

Convex Set

Line between any two points in the set stays inside the set.

โœ“ Convex

โœ— Non-convex

Convex Function

"Bowl-shaped" โ€” line between any two points lies above the curve.

f(ฮปx + (1-ฮป)y) โ‰ค ฮปf(x) + (1-ฮป)f(y)

Gradient Descent

Starting Point (x) 8
-8 8
Learning Rate 0.1
0.01 0.5
Iterations 50
10 100

๐Ÿ“Š Optimization Result

Optimum x* -1
Found x -0.9999
f(x) 0.0000
Error |x - x*| 1.28e-4
โœ“ Converged to optimum

Gradient Descent Path

Start
Path
End
f(x) = xยฒ + 2x + 1

Why Convexity Matters

Global Minimum

Local minimum = global minimum

โ†’ No "traps"

Guaranteed Convergence

Gradient descent converges

โ†’ Smooth landscape

Efficient Algorithms

Polynomial time solutions

โ†’ Well-studied theory

Duality

Strong duality often holds

โ†’ Bounds on optimum

๐ŸŽฐ Betting Applications

Portfolio Optimization

Obj: Minimize variance

s.t. Target return

Liability Hedging

Obj: Minimize cost

s.t. Risk limits

Odds Calibration

Obj: Minimize Brier score

s.t. Probs sum to 1

Resource Allocation

Obj: Maximize profit

s.t. Budget limits

Python Code

# Convex optimization with CVXPY
import cvxpy as cp
import numpy as np

# Portfolio optimization (minimize variance)
n_assets = 5
expected_returns = np.array([0.12, 0.10, 0.08, 0.15, 0.11])
cov_matrix = np.random.randn(n_assets, n_assets)
cov_matrix = cov_matrix @ cov_matrix.T  # Make positive semidefinite

# Decision variables
weights = cp.Variable(n_assets)

# Objective: minimize portfolio variance
objective = cp.Minimize(cp.quad_form(weights, cov_matrix))

# Constraints
constraints = [
    cp.sum(weights) == 1,          # Weights sum to 1
    weights >= 0,                   # No short selling
    weights @ expected_returns >= 0.10  # Target return
]

# Solve
problem = cp.Problem(objective, constraints)
problem.solve()

print(f"Optimal weights: {weights.value}")
print(f"Portfolio variance: {problem.value}")

โœ… Key Takeaways

  • โ€ข Convex = no local minima traps
  • โ€ข Gradient descent guaranteed to converge
  • โ€ข Many betting problems are convex
  • โ€ข Use CVXPY (Python) or cvx (MATLAB)
  • โ€ข Check if problem is convex before solving
  • โ€ข Non-convex: use multiple restarts

Pricing Models & Frameworks Tutorial

Built for mastery ยท Interactive learning