qctrlvisualizer.confidence_ellipse_matrix(hessian, cost, measurement_count, confidence_fraction=0.95)

Calculate a matrix that you can use to represent the confidence region of parameters that you estimated. Pass to this function the Hessian of the residual sum of squares with respect to the parameters, and use the output matrix to transform a hypersphere into a hyperellipse representing the confidence region. You can then plot this hyperellipse to visualize the confidence region using the plot_confidence_ellipses function.

Alternatively, you can apply a (2,2)-slice of the transformation matrix to a unit circle to visualize the confidence ellipse for a pair of estimated parameters.


  • hessian (np.ndarray) – The Hessian of the residual sum of squares cost with respect to the estimated parameters, HH
  • cost (float) – The residual sum of squares of the measurements with respect to the actual measurements, CRSSC_\mathrm{RSS}
  • measurement_count (int) – The number of measured data points, nn
  • confidence_fraction (float , optional) – The confidence fraction for the ellipse, α\alpha


A (p,p)(p, p)-matrix which transforms a unit hypersphere in a p-dimensional space into a hyperellipse representing the confidence region for the confidence fraction α\alpha. Here pp

Return type



From the Hessian matrix of the residual sum of squares with respect to the estimated parameters {λi}\{\lambda_i\}

Hij=2CRSSλiλj, H_{ij} = \frac{\partial^2 C_\mathrm{RSS}}{\partial \lambda_i \partial \lambda_j} ,

we can estimate the covariance matrix for the estimated parameters

Σ=(np2CRSSH)1. \Sigma = \left( \frac{n-p}{2 C_\mathrm{RSS}} H \right)^{-1} .

Finally, we can find a scaling factor zz, such that the matrix zΣ1/2z \Sigma^{1/2}

z=pF1α(np2,p2), z = \sqrt{p F_{1-\alpha} \left( \frac{n-p}{2}, \frac{p}{2} \right)} ,

where F1α(a,b)F_{1-\alpha}(a,b)F-distribution where the probability in the tail is equal to F1α(a,b)F_{1-\alpha}(a,b)

For more details, see the topic Characterizing your hardware using system identification in Boulder Opal and N. R. Draper and I. Guttman, The Statistician 44, 399 (1995).

Was this useful?