gradient {fdasrvf}R Documentation

Gradient using finite differences

Description

This function computes the gradient of f using finite differences.

Usage

gradient(f, binsize, multidimensional = FALSE)

Arguments

f

Either a numeric vector of a numeric matrix or a numeric array specifying the curve(s) that need to be differentiated.

  • If a vector, it must be of shape M and it is interpreted as a single 1-dimensional curve observed on a grid of size M.

  • If a matrix and multidimensional == FALSE, it must be of shape M \times N. In this case, it is interpreted as a sample of N curves observed on a grid of size M, unless M = 1 in which case it is interpreted as a single 1-dimensional curve observed on a grid of size M.

  • If a matrix and multidimensional == TRUE,it must be of shape L \times M and it is interpreted as a single L-dimensional curve observed on a grid of size M.

  • If a 3D array, it must be of shape L \times M \times N and it is interpreted as a sample of N L-dimensional curves observed on a grid of size M.

binsize

A numeric value specifying the size of the bins for computing finite differences.

multidimensional

A boolean specifying if the curves are multi-dimensional. This is useful when f is provided as a matrix to determine whether it is a single multi-dimensional curve or a collection of uni-dimensional curves. Defaults to FALSE.

Value

A numeric array of the same shape as the input array f storing the gradient of f obtained via finite differences.

Examples

out <- gradient(simu_data$f[, 1], mean(diff(simu_data$time)))

[Package fdasrvf version 2.2.0 Index]