standardize the array, i.e, subtract mean from every element, and divide by standard deviation in python

main.py
import numpy as np

# Create an array
arr = np.array([1, 2, 3, 4, 5])

# Subtract mean and divide by standard deviation
standardized_arr = (arr - np.mean(arr)) / np.std(arr)

print(standardized_arr)
199 chars
10 lines

related categories

gistlibby LogSnag