scaledRootMeanSquare
scaledRootMeanSquare(
x):number
Defined in: src/scaled_root_mean_square.js:22
The root mean square
computed by scaling, which is an equivalent way of computing
rootMeanSquare suitable for values whose squares leave floating point
range.
rootMeanSquare sums the squares directly, so it returns Infinity once
a value exceeds about 1e154 and 0 once every value falls below about
1e-162. This function divides through by the largest magnitude first, so
the squares it sums are all at most one.
It runs in O(n), linear time, with respect to the length of the array,
in two passes rather than one.
Parameters
Section titled “Parameters”number[]
a sample of one or more data points
Returns
Section titled “Returns”number
root mean square
Throws
Section titled “Throws”if x is empty
Example
Section titled “Example”scaledRootMeanSquare([-1, 1, -1, 1]); // => 1scaledRootMeanSquare([1e200, 2e200, 3e200]); // => 2.1602468994692866e+200