flexcode.basis_functions

Functions for evaluation of orthogonal basis functions.

Module Contents

Classes

BasisCoefs

Functions

evaluate_basis(responses, n_basis, basis_system)

Evaluates a system of basis functions.

tensor_basis(responses, n_basis, basis_fn)

Evaluates tensor basis.

cosine_basis(responses, n_basis)

Evaluates cosine basis.

fourier_basis(responses, n_basis)

Evaluates Fourier basis.

wavelet_basis(responses, n_basis[, family])

Evaluates Daubechies basis.

evaluate_basis(responses, n_basis, basis_system)[source]

Evaluates a system of basis functions.

Parameters:
  • responses (array) – An array of responses in [0, 1].

  • n_basis (integer) – The number of basis functions to calculate.

  • basis_system ({'cosine', 'Fourier', 'db4'}) – String denoting the system of orthogonal basis functions.

Returns:

A matrix of basis functions evaluations. Each row corresponds to a value of responses, each column corresponds to a basis function.

Return type:

numpy matrix

Raises:

ValueError – If the basis system isn’t recognized.

tensor_basis(responses, n_basis, basis_fn)[source]

Evaluates tensor basis.

Combines single-dimensional basis functions phi_{d}(z) to form orthogonal tensor basis $phi(z_{1}, dots, z_{D}) = prod_{d} phi_{d}(z_{d})$.

Parameters:
  • responses (numpy matrix) – A matrix of responses in [0, 1]^(n_dim). Each column corresponds to a variable, each row corresponds to an observation.

  • n_basis (list of integers) – The number of basis function for each dimension. Should have the same length as the number of columns of responses.

  • basis_fn (function) – The function which evaluates the one-dimensional basis functions.

Returns:

Returns a matrix where each column is a basis function and each row is an observation.

Return type:

numpy matrix

cosine_basis(responses, n_basis)[source]

Evaluates cosine basis.

Parameters:
  • responses (array) – An array of responses in [0, 1].

  • n_basis (integer) – The number of basis functions to evaluate.

Returns:

A matrix of cosine basis functions evaluated at responses. Each row corresponds to a value of responses, each column corresponds to a basis function.

Return type:

numpy matrix

fourier_basis(responses, n_basis)[source]

Evaluates Fourier basis.

Parameters:
  • responses (array) – An array of responses in [0, 1].

  • n_basis (integer) – The number of basis functions to evaluate.

Returns:

A matrix of Fourier basis functions evaluated at responses. Each row corresponds to a value of responses, each column corresponds to a basis function.

Return type:

numpy matrix

wavelet_basis(responses, n_basis, family='db4')[source]

Evaluates Daubechies basis.

Parameters:
  • responses (array) – An array of responses in [0, 1].

  • n_basis (integer) – The number of basis functions to evaluate.

  • family (string) – The wavelet family to evaluate.

Returns:

A matrix of Fourier basis functions evaluated at responses. Each row corresponds to a value of responses, each column corresponds to a basis function.

Return type:

numpy matrix

class BasisCoefs(coefs, basis_system, z_min, z_max, bump_threshold=None, sharpen_alpha=None)[source]

Bases: object

evaluate(z_grid)[source]