![]() |
VOOZH | about |
In NumPy, we can compute the mean, standard deviation, and variance of a given array along the second axis by two approaches first is by using inbuilt functions and second is by the formulas of the mean, standard deviation, and variance.
Method 1: Using numpy.mean(), numpy.std(), numpy.var()
Output:
[0 1 2 3 4 5 6 7 8 9] Mean: 4.5 std: 2.8722813232690143 variance: 8.25
Method 2: Using the formulas
Output:
[0 1 2 3 4 5 6 7 8 9] Mean: 4.5 std: 2.8722813232690143 variance: 8.25
Example: Comparing both inbuilt methods and formulas
Output:
[0 1 2 3 4] Mean: 2.0 2.0 std: 1.4142135623730951 1.4142135623730951 variance: 2.0 2.0