In statistics, the task is to standardize variables which are called valvulating z-scores. Comparing two standardizing variables is the function of standardizing vector. By subtracting the vector by its mean and dividing the result by the vector’s standard deviation we can standardize a vector.
Z= (x – mean)/standard deviation
- Declare a vector
- Calculate its mean and standard deviation by the functions mean() and sd().
- To create a standardized vector:
- Subtract mean from the vector
- Now divide the above result with standard deviation
 0.3325644 0.6235582 -0.8314110 -1.1224048 -1.1224048 1.2055459 0.9145521
Now we can also check whether the vector has been correctly standardized or not by checking if its mean is zero and the standard deviation is one. The answer of mean is not coming exactly zero but almost zero. Which is acceptable since it is the result of computer laws.
 0.3 -0.4 -0.4 0.1 0.4
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.