-
Notifications
You must be signed in to change notification settings - Fork 0
5. Stat
The sub-module FUSS.stat
contains functions I use for statistical analysis.
The following 2 functions may later be removed as I now know of numpy.cov
, which evaluates the co-variance matrix given data and weights.
Provides the value of one element of the co-variance matrix (so either a variance or the co-variance depending on the indices specified).
Parameters
- j (int): Column number
- k (int): Row number
- q (1D Array): Data set of first variable.
- q_r (1D Array): Error on the first data set
- u (1D Array): Data set of second variable.
- u_r (1D Array): Error on the second data set
/!\ q, q_r, u, u_r must all have the same dimension.
Returns
- Element C(j,k) of the Covariance matrix C
Creates co-variance matrix C for 2 variables. Parameters
- q (1D Array): Data set of first variable.
- q_r (1D Array): Error on the first data set
- u (1D Array): Data set of second variable.
- u_r (1D Array): Error on the second data set
/!\ q, q_r, u, u_r must all have the same dimension.
Returns
- Covariance matrix C
Makes use of cov_matrix()
.
Performs PCA on data provided. Parameters
- q (1D Array): Data set of first variable.
- q_r (1D Array): Error on the first data set
- u (1D Array): Data set of second variable.
- u_r (1D Array): Error on the second data set
Returns
- Axis ratio (b/a), rotation angle of the major axis (in degrees), rotation angle of the minor axis (also in degrees).
Creates an ellipse that best fits the data to be drawn onto the q-u plane. Parameters
- q (1D Array): Data set of first variable.
- u (1D Array): Data set of second variable.
- a (float): Length of the major axis. Just pick a number that makes the ellipse look nice on top of the data.
- alpha_dom (float): Rotation angle of the major axis (in degrees).
Returns
- The ellipse, to be used as input of the function
add_artist()
frommatplotlib.axes
Makes use of cov_el()
.
Perform a Pearson's test on the data provided. All arrays must have the same length. Parameters
- q (1D Array): Data set of first variable.
- q_r (1D Array): Error on the first data set
- u (1D Array): Data set of second variable.
- u_r (1D Array): Error on the second data set
Returns
- Pearson's coefficient
Just a linear function. Used by odr_fit
.
Parameters
- beta (1D Array): [Intercept, Gradient]
- *x (1D Array): Independent variable
Returns
- 1D Array: y (dependent variable)
Does what it says on the tin, an ODR fit.
Parameters
- x (1D Array): x
- *xr (1D Array): errors on x
- y (1D Array): y
- *yr (1D Array): errors on y
Returns
- Gradient, error on gradient, intercept, error on intercept.
email: [email protected]