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

    Function outer

    • Outer product of two vectors: the matrix of fun(x[i], y[j]). Equivalent to R's outer(). fun is "*" (default), "+", "-", "/", "^" or a function of two numbers, given as the third argument or as the option fun (giving both is a RangeError).

      Parameters

      Returns number[][]

      outer([1, 2], [1, 2, 3]);      // [[1, 2, 3], [2, 4, 6]]
      outer([1, 2], [1, 2, 3], "+"); // [[2, 3, 4], [3, 4, 5]]
    • Outer product of two vectors, with the operation in the options: outer(x, y, { fun: "+" }).

      Parameters

      Returns number[][]

      outer([1, 2], [1, 2, 3], { fun: "+" }); // [[2, 3, 4], [3, 4, 5]]