nemos.basis._basis.MultiplicativeBasis.evaluate_on_grid#

MultiplicativeBasis.evaluate_on_grid(*n_samples)[source]#

Evaluate the basis set on a grid of equi-spaced sample points.

The i-th axis of the grid will be sampled with n_samples[i] equi-spaced points. The method uses numpy.meshgrid with indexing="ij", returning matrix indexing instead of the default cartesian indexing, see Notes.

Parameters:
  • n_samples[0] – The number of points in the uniformly spaced grid. The length of n_samples must equal the number of combined bases.

  • ... – The number of points in the uniformly spaced grid. The length of n_samples must equal the number of combined bases.

  • n_samples[n] – The number of points in the uniformly spaced grid. The length of n_samples must equal the number of combined bases.

  • n_samples (int)

Return type:

Tuple[Tuple[NDArray], NDArray]

Returns:

  • *Xs – A tuple of arrays containing the meshgrid values, one element for each of the n dimension of the grid, where n equals to the number of inputs. The size of Xs[i] is (n_samples[0], ... , n_samples[n]).

  • Y – The basis function evaluated at the samples, shape (n_samples[0], ... , n_samples[n], number of basis).

Raises:
  • ValueError – If the time point number is inconsistent between inputs or if the number of inputs doesn’t match what the Basis object requires.

  • ValueError – If one of the n_samples is <= 0.

Notes

Setting indexing = 'ij' returns a meshgrid with matrix indexing. In the N-D case with inputs of size \(M_1,...,M_N\), outputs are of shape \((M_1, M_2, M_3, ....,M_N)\). This differs from the numpy.meshgrid default, which uses Cartesian indexing. For the same input, Cartesian indexing would return an output of shape \((M_2, M_1, M_3, ....,M_N)\).

Examples

>>> import numpy as np
>>> import nemos as nmo
>>> mult_basis = nmo.basis.BSplineEval(4) * nmo.basis.RaisedCosineLinearEval(5)
>>> X, Y, Z = mult_basis.evaluate_on_grid(10, 10)