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

    Function scale

    • Centre and scale the columns of a matrix (array of rows; a vector is one column). Equivalent to R's scale(). center and scale report the values used (R's attributes), when any.

      Parameters

      Returns { center?: number[]; scale?: number[]; scaled: number[][] }

      • Optionalcenter?: number[]

        The values subtracted from each column (R's scaled:center attribute); absent with center: false.

      • Optionalscale?: number[]

        The values each column was divided by (R's scaled:scale attribute); absent with scale: false.

      • scaled: number[][]

        The centred and scaled matrix, as an array of rows (R's returned matrix).

      scale([1, 2, 3]); // { scaled: [[-1], [0], [1]], center: [2], scale: [1] }