confidence_ellipse_matrix
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.
Parameters
- hessian (np.ndarray) – The Hessian of the residual sum of squares cost with respect to the estimated parameters, . Must be a square matrix.
- cost (float) – The residual sum of squares of the measurements with respect to the actual measurements, . Must be positive.
- measurement_count (int) – The number of measured data points, . Must be positive.
- confidence_fraction (float , optional) – The confidence fraction for the ellipse, . If provided, must be between 0 and 1. Defaults to 0.95.
Returns
A -matrix which transforms a unit hypersphere in a p-dimensional space into a hyperellipse representing the confidence region for the confidence fraction . Here is the dimension of the Hessian matrix.
Return type
np.ndarray
Notes
From the Hessian matrix of the residual sum of squares with respect to the estimated parameters ,
we can estimate the covariance matrix for the estimated parameters
Finally, we can find a scaling factor , such that the matrix transforms the coordinates of a unit hypersphere in a p-dimensional space into a hyperellipse representing the confidence region
where is the point of the F-distribution where the probability in the tail is equal to .
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).