Documentation

Functions

cookies_statistics.backsub

cookies_statistics.backsub(A, b)

Solves Ax=b using back substitution.

Parameters:
  • A (np.array) – An upper triangular square matrix.

  • B (np.array) – A vector.

Return type:

np.array

cookies_statistics.upper_triangularize

cookies_statistics.upper_triangularize(X)

This function repeatedly applies Householder transformations to A nxm matrix X (n >= m) until it becomes an upper triangular matrix, and then returns it.

Parameters:

X (np.array) – A nxm matrix (n >= m).

Return type:

np.array

cookies_statistics.lsq_householder

cookies_statistics.lsq_householder(Z, y)

Solve the least squares problem using Householder transformations. This function returns a tuple of the coefficient vector and the sum of squared errors.

Parameters:
  • Z (np.array) – A Nxm data matrix (N >= m).

  • y (np.array) – A vector of length N.

Return type:

np.array, float

Example

import numpy as np
import cookies_statistics as cs

Z = np.array([[3., -2.], [0., 3.], [4.,  4.]])
y = np.array([3., 5., 4.])
print(cs.lsq_householder(Z, y))
#  --> (array([0.76, 0.6 ]), 4.0)

Classes