Standardize numeric data to zero mean and unit population variance along a selected axis:
z=σx−μHere, x is an input value, μ is the mean of its selected slice, σ is the population standard deviation of that slice, and z is the standardized value. Use column-wise slices when axis=0 and row-wise slices when axis=1. If a slice has standard deviation at most eps, return zeros for that slice. Return a NumPy array.
Input: X = [[1, 2], [3, 6], [5, 10]], axis = 0, eps = 1e-8
Output: [[-1.224745, -1.224745], [0.0, 0.0], [1.224745, 1.224745]]
Explanation: Both columns have the same relative spacing, so their standardized values match.
Use np.mean(..., keepdims=True) and np.std(..., keepdims=True) along axis.
Use np.where(std > eps, std, 1.0) before dividing.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number
Standardize numeric data to zero mean and unit population variance along a selected axis:
z=σx−μHere, x is an input value, μ is the mean of its selected slice, σ is the population standard deviation of that slice, and z is the standardized value. Use column-wise slices when axis=0 and row-wise slices when axis=1. If a slice has standard deviation at most eps, return zeros for that slice. Return a NumPy array.
Input: X = [[1, 2], [3, 6], [5, 10]], axis = 0, eps = 1e-8
Output: [[-1.224745, -1.224745], [0.0, 0.0], [1.224745, 1.224745]]
Explanation: Both columns have the same relative spacing, so their standardized values match.
Use np.mean(..., keepdims=True) and np.std(..., keepdims=True) along axis.
Use np.where(std > eps, std, 1.0) before dividing.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number