The normal equation computes regression coefficients for a surrogate model from measured responses. With a quadratic model, construct a design matrix X containing a constant, threshold, and threshold-squared column, then solve β = (XᵀX)⁻¹Xᵀy. Equal numbers of measurements and parameters can produce an exact fit; with more measurements, the approximation error is generally nonzero. section 4.1.3
Fit a quadratic profit model
For threshold measurements and aggregate profit measurements, use NumPy: X = np.array([np.ones(len(y)), x, x**2]).T; beta = np.linalg.inv(X.T @ X) @ (X.T @ y). Apply the resulting coefficients to a new XHat matrix to estimate profit between measured thresholds. section 4.1.3
Figure 4.9 Analyze stage. In this stage, you build a model to interpolate between the measured values of markout_profit(threshold) and find the value of threshold that optimizes (maximizes) the interpolated value of markout_profit(threshold).
Trace the analyze workflow from measured markout profit through surrogate-model fitting to threshold optimization. section 4.1.3
