3

Absolute Error

Unsolved
Prob. and Stats

Difficulty: 2 | Problem written by mesakarghm
Problem reported in interviews at

Amazon
Apple
Facebook
Google
Netflix

If x is the actual value of a quantity and x0 is the predicted value, then the absolute error can be calculated using the formula: 

\(\delta x = x_0 - x\)

For multiple predictions, the arithmetic mean of absolute errors of individual measurements should be the final absolute error. 

\(\delta x = {\sum |x_0 - x| \over n}\)

x0 is the predicted value

x is the actual value 

and n is the length of array  

For a given set of arrays (two numeric lists of same length with actual value as the first list and predicted value as the second list), calculate and return the absolute error. 

Sample Input:
<class 'list'>
arr1: [1, 2, 3]
arr2: [3, 4, 5]

Expected Output:
<class 'float'>
2.0

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Rem cupiditate debitis non numquam hic, qui corrupti consequuntur animi voluptate quia amet, necessitatibus laudantium inventore alias fugiat laborum sunt tempore ea sapiente voluptas voluptatem, esse pariatur dignissimos aliquid commodi vitae consequatur expedita voluptatum aspernatur. Hic quo eaque, velit corporis sed deserunt eligendi maxime vitae labore cumque ullam enim?

Consectetur quam in eveniet. Nemo deserunt consequuntur facere, voluptate esse facilis delectus dolorum, autem obcaecati architecto, enim error a dolore aperiam culpa quod animi ea eveniet ipsa quam?

Porro odio temporibus eveniet numquam, nihil non ducimus reprehenderit nostrum corrupti cumque quisquam repellat dolorum amet? Perspiciatis quos nulla voluptas deserunt doloribus possimus impedit tempora aperiam, dignissimos perspiciatis perferendis tempora inventore sit officia, tenetur est excepturi soluta voluptatem enim culpa, ad rerum nobis earum, officia nisi dolorem quo repellendus quam et mollitia modi a delectus doloremque. Vel magni neque alias nobis nulla voluptate?

This is a premium feature.
To access this and other such features, click on upgrade below.

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)