Learn R Programming

BayesfMRI (version 0.3.11)

cderiv: Central derivative

Description

Take the central derivative of numeric vectors by averaging the forward and backward differences.

Usage

cderiv(x)

Value

A matrix or vector the same dimensions as x, with the derivative taken for each column of x. The first and last rows may need to be deleted, depending on the application.

Arguments

x

A numeric matrix, or a vector which will be converted to a single-column matrix.

Examples

Run this code
x <- cderiv(seq(5))
stopifnot(all(x == c(.5, 1, 1, 1, .5)))

Run the code above in your browser using DataLab