Finding square root using numpy.sqrt()
This function returns a non-negative(or positive) square root of each element of the given array.
It takes input array whose whose square-roots are required.
It returns the array which has positive square root of each element of input array.
import numpy as np a=np.array([[1,21,43],[65,7,80]]) print(np.sqrt(a))
[[1. 4.58257569 6.55743852] [8.06225775 2.64575131 8.94427191]]
Finding standard deviation using numpy.std():
It is used to compute the standard deviation of the array elements along the specified axis. Standard Deviation is used to measure that how the spread of data distribution is in the given array.
numpy.std(a, axis=None, dtype=None, out=None, ddof=0, keepdims= <class numpy._globals._NoValue>)
- a: The input array whose elements are used to calculate the standard deviation.
- axis: It is optional.The axis along which we want to calculate the standard deviation.
- dtype: It defines the data type. It is used to calculate the standard deviation.
- out: It is used to define the output array in which the result is to be placed.
- ddof: Delta Degrees of Freedom,This N-ddof divisor is used in calculations, where N represent the number of elements. It is by default 0.
- keepdims: It is optional. When the value is true.It will leave the reduced axis as dimensions with size one in the resultant.
It returns a new array which has the standard deviation. If out is None,then it will return the output array’s reference.
import numpy as np a=np.array([[1,12,34],[56,70,8]]) print(np.std(a))