Root Mean Square Error
Problem statement
Given equal-length arrays of predicted and actual integer values, compute the root mean square error: the square root of the mean of the squared pairwise differences. Return the result rounded to exactly six digits after the decimal point.
Function
rootMeanSquareError(predicted: int[], actual: int[]) → StringExamples
Example 1
predicted = [1,2,3]actual = [1,2,3]return = "0.000000"All differences are zero.
Example 2
predicted = [2,4]actual = [0,0]return = "3.162278"The mean squared error is ten, whose square root is approximately 3.16227766.
Constraints
1 <= predicted.length = actual.length <= 100000|predicted[i]|, |actual[i]| <= 100000