Search

Search papers and lessons

Min-Max Normalization

Level 2 · 9 min read

Min-max normalization rescales a list of numbers so the smallest becomes 0 and the largest becomes 1, with everything else placed in between by a straight-line rule.

On this page

  • Colour = topic mix
  • Linear algebra
  • Discrete math
  • Neural network basics
  • Sign in to see your progress

TL;DR

Min-max normalization rescales a list of numbers onto a fixed range, usually from 0 to 1. The smallest value becomes 0, the largest becomes 1, and every other value lands in between at the spot a straight-line rule gives it. The shape of the data does not change; only the scale and the starting point do.

It is the simplest way to put features measured in different units, such as metres and dollars, on a common footing before a model compares them.

Where you'll see it: preparing inputs for K-Means Clustering and nearest-neighbour methods, where a feature in the thousands would otherwise drown out a feature between 0 and 1, and feeding pixel values or sensor readings into a Feedforward Neural Network.

Intuition

Suppose you record the height of every child in a class, in centimetres, and want to compare them on a ruler that runs from the shortest child to the tallest. The shortest child sits at the zero mark, the tallest at the one mark, and everyone else is placed proportionally in between. A child exactly halfway between the two extremes lands at 0.5.

That is all min-max normalization does. It keeps the order of the values and the relative gaps between them, but it stretches or shrinks the whole list so it fits a standard window.

Why bother? Many methods measure how far apart two data points are. If one feature is a salary in the tens of thousands and another is an age between 18 and 90, the salary difference dominates every distance, and the age barely counts. Putting both on a 0 to 1 scale lets each feature speak with a comparable voice.

02468101200.51raw value xnormalized value
  • min-max on data from 2 to 10
The data run from 2 to 10. The rule draws a straight line through (2, 0) and (10, 1), so every raw value maps to exactly one normalized value between them.

The math

Definition

Definition: Min-max normalization

Given a set of values with smallest value xmin⁡x_{\min} and largest value xmax⁡x_{\max}, with xmax⁡>xmin⁡x_{\max} \gt x_{\min}, the min-max normalization of a value xx is

x′=x−xmin⁡xmax⁡−xmin⁡.x' = \frac{x - x_{\min}}{x_{\max} - x_{\min}}.

The result x′x' lies between 0 and 1 for every value in the set.

Here xx is the raw value and x′x' is its new value. The subtraction x−xmin⁡x - x_{\min} measures how far xx sits above the bottom of the data. The denominator xmax⁡−xmin⁡x_{\max} - x_{\min} is the width of the data, called the range. Dividing one by the other gives the fraction of the way from the bottom to the top.

If you want a different target window [a,b][a, b], the same idea gives

x′=a+(x−xmin⁡) (b−a)xmax⁡−xmin⁡.x' = a + \frac{(x - x_{\min})\,(b - a)}{x_{\max} - x_{\min}}.

For [a,b]=[−1,1][a, b] = [-1, 1], you get x′=−1+2 x−xmin⁡xmax⁡−xmin⁡x' = -1 + 2\,\frac{x - x_{\min}}{x_{\max} - x_{\min}}.

Why it is a linear transformation

The rule has two parts. The factor 1xmax⁡−xmin⁡\frac{1}{x_{\max} - x_{\min}} multiplies xx by a fixed number, which stretches or shrinks the line. The term −xmin⁡xmax⁡−xmin⁡-\frac{x_{\min}}{x_{\max} - x_{\min}} then slides the result along the line. Scaling is a Linear Transformation, and sliding is a shift. Together they form a map of the form x′=s x+tx' = s\,x + t, a straight line in the graph of input against output. Because of the shift, the map does not fix the origin in general, so it is a linear rescaling plus a shift rather than a pure linear map. Either way, it is a straight line, so it never bends the data.

What it preserves and what it does not

Since the map is a straight line with a positive slope, it keeps the order of the values and the ratios of gaps: if one gap is twice another before normalization, it is twice the other afterwards. It does not change the shape of the distribution. A skewed list (one with a long tail on one side) stays skewed, and a bell-shaped list stays bell-shaped. Min-max normalization changes the units, not the shape. (To change the shape you need a different tool, such as a Logarithm.)

Worked examples

Example
1. A tiny list you can check by hand

Take the values 2, 4, 6, 10.

  1. Find the extremes: xmin⁡=2x_{\min} = 2 and xmax⁡=10x_{\max} = 10.
  2. Compute the range: 10−2=810 - 2 = 8.
  3. Normalize each value by x−28\frac{x - 2}{8}:
    • 2→08=02 \to \frac{0}{8} = 0
    • 4→28=0.254 \to \frac{2}{8} = 0.25
    • 6→48=0.56 \to \frac{4}{8} = 0.5
    • 10→88=110 \to \frac{8}{8} = 1

Interpretation: the smallest value maps to 0, the largest to 1, and the value 6, which sits exactly halfway between 2 and 10, lands on 0.5. The gaps 2, 2, 4 became 0.25, 0.25, 0.5, so the proportions are kept.

Example
2. Ages on a common scale (the textbook case)

A survey records ages 18, 35, 50 and 72. The range is 72−18=5472 - 18 = 54.

  1. Scale to [0,1][0, 1]: x′=x−1854x' = \frac{x - 18}{54}.
    • 18→018 \to 0
    • 35→1754≈0.31535 \to \frac{17}{54} \approx 0.315
    • 50→3254≈0.59350 \to \frac{32}{54} \approx 0.593
    • 72→172 \to 1
  2. Scale the same ages to [−1,1][-1, 1] using x′=−1+2 x−1854x' = -1 + 2\,\frac{x - 18}{54}. For age 35: −1+2×0.315≈−0.370-1 + 2 \times 0.315 \approx -0.370.

Interpretation: the 35-year-old sits about 31.5 percent of the way from the youngest to the oldest respondent. The choice of window ([0,1][0, 1] or [−1,1][-1, 1]) is only a convention; the information is the same, and the second version is often preferred when the values should be centred around zero.

Example
3. Two features for a housing model

A Feedforward Neural Network predicts flat prices from floor area and bedroom count. In a training set, areas run from 45 to 320 square metres, and bedrooms run from 1 to 5. Normalize a flat of 110 square metres with 3 bedrooms.

  1. Area: 110−45320−45=65275≈0.236\frac{110 - 45}{320 - 45} = \frac{65}{275} \approx 0.236.
  2. Bedrooms: 3−15−1=24=0.5\frac{3 - 1}{5 - 1} = \frac{2}{4} = 0.5.

The flat becomes the input pair (0.236, 0.5)(0.236,\ 0.5). Without scaling, the area would be a number near 100 and the bedroom count a number near 3, so a distance-based method such as K-Means Clustering would treat area as more than thirty times more important than bedrooms for no real reason. After scaling, both features are between 0 and 1 and can be compared fairly.

Tradeoffs and failure modes

Min-max normalization is simple and easy to read, but it depends entirely on the two extreme values. Several things go wrong in practice.

SituationWhat goes wrongBetter choice
One extreme outlier in the dataThe outlier sets xmax⁡x_{\max}, and every ordinary value is squeezed into a tiny band near 0.Clip or remove outliers first, or use a robust scaler based on the median (the middle value when the data are sorted) and the interquartile range (the width of the middle half of the data).
A new value falls outside the training rangeIt maps below 0 or above 1, which a model may never have seen.Clip the value to the range, or accept the out-of-range value and check the model's behaviour.
Data should be centred around zero with unit spreadMin-max gives a fixed window, not a zero mean.Standardize with the z-score, (x−μ)/σ(x - \mu)/\sigma, where μ\mu is the mean and σ\sigma the standard deviation (see Mean and Variance).
Features feed a model that normalizes internallyThe extra scaling adds nothing, and a poorly chosen range can hide structure.Skip it, or let the model's own layers handle it (see Batch Normalization).

The most common mistake is to fit the minimum and maximum on the full data set, including the test set. Compute xmin⁡x_{\min} and xmax⁡x_{\max} on the training data only (see Train, Validation and Test Sets), store them, and apply the same two numbers to every later input. Otherwise information from the test data leaks into the training process.

History

Rescaling a variable onto a fixed range is an old, practical habit: it lets people compare measurements taken in different units on one scale. Min-max normalization has no single named inventor. Its use became widespread with the growth of machine learning in the late twentieth century, when methods that compare points by distance, such as clustering and nearest-neighbour search, made it obvious that features with large numbers could dominate everything else. Today it is a standard preprocessing step in most machine learning toolkits, usually sitting next to z-score standardization.

Recap

Min-max normalization maps the smallest value to 0 and the largest to 1 with one straight line, x′=(x−xmin⁡)/(xmax⁡−xmin⁡)x' = (x - x_{\min})/(x_{\max} - x_{\min}). It keeps order and relative gaps, changes only units, and is fragile to outliers and to values outside the training range. It leads next to z-score standardization, which centres data using the mean and spread, and to Batch Normalization, which learns similar rescaling inside a network and helps Gradient Descent train smoothly.

Check yourself

QuestionUnder the default rule, which values do the smallest and largest entries of a data set become, and what does every other value become?Show answer

The smallest value becomes 0 and the largest becomes 1. Every other value becomes x−xmin⁡xmax⁡−xmin⁡\frac{x - x_{\min}}{x_{\max} - x_{\min}}, which lies strictly between 0 and 1 when xx is between the extremes. The rule is a straight line, so the order of the values is kept.

QuestionA list is 5, 9, 13, 21. What are the min-max normalized values of 9 and 13?Show answer

The minimum is 5 and the maximum is 21, so the range is 21−5=1621 - 5 = 16. For 9: 9−516=416=0.25\frac{9 - 5}{16} = \frac{4}{16} = 0.25. For 13: 13−516=816=0.5\frac{13 - 5}{16} = \frac{8}{16} = 0.5.

QuestionWhy does one very large outlier make ordinary values hard to tell apart after min-max normalization?Show answer

The outlier becomes xmax⁡x_{\max}, which makes the range xmax⁡−xmin⁡x_{\max} - x_{\min} very large. Every ordinary value is divided by that large range, so their normalized values are crowded into a small interval near 0. The order is kept, but the gaps between typical values shrink to almost nothing, so a model sees them as nearly identical.

QuestionYou fit min-max normalization on training data with a range of 10 to 50. A test value of 60 arrives. What is its normalized value, and should you refit the minimum and maximum to include it?Show answer

The normalized value is 60−1050−10=5040=1.25\frac{60 - 10}{50 - 10} = \frac{50}{40} = 1.25, which lies outside [0,1][0, 1]. You should not refit on the test value. Refitting would change the scale the model was trained on and would use test information during training. Keep the training minimum and maximum, and decide separately whether to clip values such as 1.25 to 1 or leave them as they are.

QuestionA dataset of household incomes has most values between 20 and 80 thousand but a few values near 5 million. Name one problem with min-max normalization here and one alternative.Show answer

The few very large incomes set xmax⁡x_{\max} near 5 million, so the typical incomes between 20 and 80 thousand all collapse into a narrow band near 0. An alternative is to clip or remove the extreme values before scaling, or to use a robust scaler based on the median and interquartile range, which the few large values cannot distort.

Sources