Which of these two numerical methods for z-score normalisation is preferable, in multivariate linear regression? In the exercise Exercise 3: Multivariate Linear Regression, by Andrew Ng, the author suggests to "scale both types of inputs by their standard deviations and set their means to zero".

$$x_{n e w}=\frac{x-\mu}{\sigma}$$

Method 1

The author provides the following Matlab (and Octave) code to scale the inputs.

x = [ones(m, 1), x];
sigma = std(x);
mu = mean(x);
x(:,2) = (x(:,2) - mu(2))./ sigma(2);
x(:,3) = (x(:,3) - mu(3))./ sigma(3);


Method 2

But why not simply scale the inputs between zero and one, or, divide by the maximum?

x_range=max(x)
x(:,2) = (x(:,2)/x_range(2));
x(:,3) = (x(:,3)/x_range(3));


I have done the exercise with method 2 and these are the results.



Question

Is there a computational advantage with the first method over the second method?
No, there is no computational advantage of the second method over the first, if you neglect the computational requirements for the calculation of $\sigma$ and $\mu$.

We generally use the first method for better results. This is because if you separate your dataset into train and test data, then you may normalise the train data perfectly between $0$ and $1$ by taking $max$ and $min$ from the train dataset. Your algorithm will only see data between $0-1$, but there is no way to ensure normalising the test data on the same $max$ and $min$ will result in the data being between $0$ and $1$..

So a better way is to use the Gaussian Distribution method, as the only assumption it makes is the data distribution is Gaussian which is just about true for any phenomenon (after some functional transformations which might be handled by the ML algorithm). I answered a similar question here.