Open reclara opened 2 years ago
Hello ! You can use the following function. The signal parameter is a 2D array with two columns containing the medio-lateral and antero-posterior coordinates. Note that this function computes precisely the "prediction ellipse area", i.e. the area of the ellipse that would contain a new point with a probability of 0.95. The formula comes from the article Ellipse area calculations and their applicability in posturography, P. Schubert and M. Kirchner. 2014, Gait & Posture.
from scipy import stats
def confidence_ellipse_area(signal):
n = len(signal) signal = signal - np.mean(signal, axis=0)
cov = (1/n)*np.sum(signal[:,0]*signal[:,1]))
s_ml = np.std(signal[:,0])
s_ap = np.std(signal[:,1])
confidence = 0.95
quant = stats.f.ppf(confidence, 2, len(sig)-2)
coeff = ((n+1)*(n-1)) / (n*(n-2))
det = (s_ml**2)*(s_ap**2) - cov**2
ellipse_area = 2 * np.pi * quant * np.sqrt(det) * coeff
return ellipse_area
Hi, thank you for this contribution! I would like to calculate the 95% confidence ellipse area, but struggle with extracting it from the rest of your script, as there are a lot of functions and defintions.
Is there a way you could send me an example to calculate the ellipse area for a simple 2D array (x- and y-values of position in room)? That would really help, I can't find anything in the internet.
Thanks a lot!!