circuit_knitting.utils.metrics.chi2_distance¶
- chi2_distance(target, obs)[source]¶
Measure the Chi-square distance.
The Chi-Square distance is a measure of statistically correlation between two feature vectors and is defined as $ sum_i frac{(x_i - y_i)^2}{x_i + y_i}$.
Deprecated since version 0.7.0: The function
circuit_knitting.utils.metrics.chi2_distance()
is deprecated as of circuit-knitting-toolbox 0.7.0. It will be removed no sooner than CKT v0.8.0.Examples: >>> chi2_distance(np.array([0.1, 0.1, 0.3, 0.5]), np.array([0.25, 0.25, 0.25, 0.25])) 0.21645021645021645
>>> chi2_distance(np.array([0.25, 0.25, 0.25, 0.25]), np.array([0.25, 0.25, 0.25, 0.25])) 0
- Parameters:
target – The target feature vector
obs – The actually observed feature vector
- Returns:
The computed distance
- Raises:
Exception – The target is not a numpy array or dictionary