rStats.js v1.3.0
    Preparing search index...

    Function grad

    • Gradient of a scalar function of a vector. Equivalent to numDeriv::grad(func, x, method) in R.

      Parameters

      • func: (x: number[]) => number
      • x: readonly number[]
      • options: DerivOptions = {}

      Returns number[]

      grad((x) => x[0]! ** 2 + Math.sin(x[1]!), [1, 0]); // [2, 1]