1

Min Max Normalization on Arbitrary Values

Unsolved
Fundamentals

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

Amazon
Apple
Facebook
Google
Netflix

Data Normalization / Scaling is an important part of data preprocessing. To rescale the data using Min Max Normalization between a set of arbitary values [a,b], we can use the formula: 

\(x' = a + {(x - min(x)) \over max(x) - min(x)} * (b-a)\)

Write a function minMax(x,a,b) which scales the input array (1D list) between the values a and b. 

Sample Input:
<class 'list'>
x: [100, 50, 10, 9]
a: 0
b: 5

Expected Output:
<class 'list'>
[5.0, 2.25, 0.05, 0.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.

Laborum architecto maiores non molestias dolorum natus placeat, sed laborum eaque temporibus, rem dolor libero impedit amet, dolor sequi suscipit, dolore ratione earum architecto sunt rem doloribus nesciunt beatae?

Culpa minus similique blanditiis est obcaecati veniam, saepe maxime reiciendis debitis sequi in quo rem atque porro, tempore autem quod laudantium, ratione numquam rerum delectus aliquam quibusdam distinctio nesciunt quaerat ullam tempore?

Corporis alias distinctio repellat obcaecati dignissimos asperiores error dolorem? Laborum quis ratione dolores neque nihil saepe aperiam? Autem reprehenderit sit vel soluta accusamus repellat corporis perspiciatis nulla rerum temporibus.

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)