All formulas

Statistics

Root mean squared error

stats.rmseAlso called root mean squared error, rmse, root mean square error, rms error

RMSE=1n∑i=1n(yi−y^i)2\mathrm{RMSE} = \sqrt{\frac{1}{n}\sum_{i=1}^{n} (y_i - \hat{y}_i)^2}

Square root of the mean squared error, in the units of the data.

Notation

yy

observed values

y ∈ ℝn

y^\hat{y}

predicted values

ŷ ∈ ℝn

nn

number of observations

Size, at least 1

RMSE\mathrm{RMSE}

Result: the root mean squared error

scalar

Worked examples

Each result is solved exactly and confirmed by two independent computations.

  1. Given

    y=[1,2,3],y^=[1,1,5]y = [1, 2, 3], \hat{y} = [1, 1, 5]

    Result

    RMSE=153\displaystyle \mathrm{RMSE} = \frac{\sqrt{15}}{3}

    ≈ 1.29099444874

  2. Given

    y=[0,0],y^=[3,4]y = [0, 0], \hat{y} = [3, 4]

    Result

    RMSE=522\displaystyle \mathrm{RMSE} = \frac{5 \sqrt{2}}{2}

    ≈ 3.53553390593

  3. Given

    y=[0.5],y^=[0.25]y = [0.5], \hat{y} = [0.25]

    Result

    RMSE=14\displaystyle \mathrm{RMSE} = \frac{1}{4}

    ≈ 0.25

Common mistakes

  • Returns the mean squared error

    The square root is missing.

    Fix: Take the square root of the mean.

  • Square root of the sum

    The squared errors are summed, not averaged, before the root; the result is sqrt(n) times too large.

    Fix: Divide by n inside the square root.

Source

  • Murphy 2022

    Murphy, Kevin P. Probabilistic Machine Learning: An Introduction. MIT Press, 2022.