Skip to content

5. Stat

Heloise edited this page Mar 21, 2017 · 11 revisions

The sub-module FUSS.stat contains functions I use for statistical analysis.

Principal Components Analysis (PCA)

Co-variance Matrix

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.

cov_el():

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

cov_mat()

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

pca()

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).

draw_ellipse()

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() from matplotlib.axes
Clone this wiki locally