esat.model package#

Submodules#

esat.model.batch_sa module#

esat.model.ls_nmf module#

class esat.model.ls_nmf.LSNMF#

Bases: object

static update(V: ndarray, We: ndarray, W: ndarray, H: ndarray, hold_h: bool = False)#

The update procedure for the least-squares nmf (ls-nmf) algorithm.

The ls-nmf algorithm is described in the publication ‘LS-NMF: A modified non-negative matrix factorization algorithm utilizing uncertainty estimates’ (https://doi.org/10.1186/1471-2105-7-175).

Parameters:
  • V (np.ndarray) – The input dataset.

  • We (np.ndarray) – The weights calculated from the input uncertainty dataset.

  • W (np.ndarray) – The factor contribution matrix.

  • H (np.ndarray) – The factor profile matrix.

  • hold_h (bool) – If True, the H matrix is not updated.

Returns:

The updated W and H matrices.

Return type:

np.ndarray, np.ndarray

esat.model.recombinator module#

class esat.model.recombinator.OptimalBlockLength(b_star_sb, b_star_cb)#

Bases: NamedTuple

b_star_cb: float#

Alias for field number 1

b_star_sb: float#

Alias for field number 0

esat.model.recombinator.lam(kk: ndarray) ndarray#

Helper function, calculates the flattop kernel weights.

Adapted for Python August 12, 2018 by Michael C. Nowotny

esat.model.recombinator.mlag(x: ndarray, n: int | None = 1, init: float | None = 0.0) ndarray#

Purpose: generates a matrix of n lags from a matrix (or vector) containing a set of vectors (For use in var routines)

Usage: xlag = mlag(x,nlag) or: xlag1 = mlag(x), which defaults to 1-lag where: x is a nobs by nvar NumPy array

Parameters:
  • x (nlag = # of contiguous lags for each vector in)

  • = (init) – (default = 0)

Returns: xlag = a matrix of lags (nobs x nvar*nlag) x1(t-1), x1(t-2), … x1(t-nlag), x2(t-1), … x2(t-nlag) …

original Matlab version written by: James P. LeSage, Dept of Economics University of Toledo 2801 W. Bancroft St, Toledo, OH 43606 jpl@jpl.econ.utoledo.edu

Adapted for Python August 12, 2018 by Michael C. Nowotny

esat.model.recombinator.optimal_block_length(data: ndarray) Sequence[OptimalBlockLength]#

This is a function to select the optimal (in the sense of minimising the MSE of the estimator of the long-run variance) block length for the stationary bootstrap or circular bootstrap. The code follows Politis and White, 2001, “Automatic Block-Length Selection for the Dependent Bootstrap”.

DECEMBER 2007: CORRECTED TO DEAL WITH ERROR IN LAHIRI’S PAPER, PUBLISHED BY NORDMAN IN THE ANNALS OF STATISTICS

NOTE: The optimal average block length for the stationary bootstrap,

and it does not need to be an integer. The optimal block length for the circular bootstrap should be an integer. Politis and White suggest rounding the output UP to the nearest integer.

Args:

data, an nxk matrix

Returns: a 2xk NumPy array of optimal bootstrap block lengths,

[[b_star_sb], [b_star_cb]], where b_star_sb: optimal block length for stationary bootstrap b_star_cb: optimal block length for circular bootstrap

original Matlab version written by: Andrew Patton

4 December, 2002 Revised (to include CB): 13 January, 2003.

Helpful suggestions for this code were received from Dimitris Politis and Kevin Sheppard.

Modified 23.8.2003 by Kevin Sheppard for speed issues

Adapted for Python August 12, 2018 by Michael C. Nowotny

esat.model.sa module#

esat.model.ws_nmf module#

class esat.model.ws_nmf.WSNMF#

Bases: object

static update(V: ndarray, We: ndarray, W: ndarray, H: ndarray)#

Weighted Semi-NMF algorithm.

The details of the semi-nmf algorithm are described in ‘Convex and Semi-Nonnegative Matrix Factorizations’ (https://doi.org/10.1109/TPAMI.2008.277). The algorithm described here does not include the use of uncertainty or weights. The paper ‘Semi-NMF and Weighted Semi-NMF Algorithms Comparison’ by Eric Velten de Melo and Jacques Wainer provides some additional details for part of the weighted semi-NMF algorithm as defined in this function.

The update procedure defined in this function was created by merging the main concepts of these two papers.

Parameters:
  • V (np.ndarray) – The input dataset.

  • We (np.ndarray) – The weights calculated from the input uncertainty dataset.

  • W (np.ndarray) – The factor contribution matrix, prior W is not used by this algorithm but provided here for testing.

  • H (np.ndarray) – The factor profile matrix.

Returns:

The updated W and H matrices.

Return type:

np.ndarray, np.ndarray

Module contents#