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, H. Must be a square matrix.
- cost (float) – The residual sum of squares of the measurements with respect to the actual measurements, CRSS. Must be positive.
- measurement_count (int) – The number of measured data points, n. 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 (p,p)-matrix which transforms a unit hypersphere in a p-dimensional space into a hyperellipse representing the confidence region for the confidence fraction α. Here p 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 {λi},
Hij=∂λi∂λj∂2CRSS,we can estimate the covariance matrix for the estimated parameters
Σ=(2CRSSn−pH)−1.Finally, we can find a scaling factor z, such that the matrix zΣ1/2 transforms the coordinates of a unit hypersphere in a p-dimensional space into a hyperellipse representing the confidence region
z=pF1−α(2n−p,2p),where F1−α(a,b) is the point of the F-distribution where the probability in the tail is equal to F1−α(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).