sparse_diff#

pygam.penalties.sparse_diff(array, n=1, axis=-1)[source]#

A ported sparse version of np.diff. Uses recursion to compute higher order differences.

Parameters:
arraysparse array
nint, default: 1

differencing order

axisint, default: -1

axis along which differences are computed

Returns:
diff_arraysparse array

same shape as input array, but ‘axis’ dimension is smaller by ‘n’.