In this post we are going to have a look at some of the mathematical functions which can be used with numpy arrays.Also there will be details regarding the syntax of these functions.There will be many mathematical functions to be used but this post will cover only the mostly used functions.
Hello Readers,
This post is the third and final post of the tri series articles on the Mathematical functions for Numpy Arrays.We are going to take a look at some mathematical functions which can be used with numpy arrays. Also these functions will be very helpful while doing some common mathematical operations.
Following is the list of functions which we are going to take a look at:
1. mean
mean() function is used to calculate the average of the numpy array values. Also we can specify the axis value to calculate the mean along different axes. Syntax to use the mean function is arr_ref.mean() with optional parameter as axis which can have value as 1 or 0.
The following code snippet specifies the output of using the mean function without specifying the axis parameter:
The following code snippet specifies the result of specifying the axis parameter with value as 0. So the calculation is done along the each column.
The following code snippet specifies the result of specifying the axis parameter with value as 1. So the calculation is done along the each row.
The following code snippet specifies the output of using the mean function without specifying the axis parameter:
The following code snippet specifies the result of specifying the axis parameter with value as 0. So the calculation is done along the each column.
The following code snippet specifies the result of specifying the axis parameter with value as 1. So the calculation is done along the each row.
2. std
std() function is a method which helps to determine the standard deviation of the values within numpy.Also we get to estimate the spread of the values inside the array.The syntax for using the std function is arr_ref.std() with an optional axis parameter. In the given syntax the arr_ref is the numpy array. Optional axis parameter can take the value of 1 and 0.
Following code snippet specifies the code and the result of the std function without the axis parameter.
Following code snippet specifies the result with the axis parameter with value 0 along each column.
Following code snippet specifies the result with the axis parameter with value 1 along each row.
std() function is a method which helps to determine the standard deviation of the values within numpy.Also we get to estimate the spread of the values inside the array.The syntax for using the std function is arr_ref.std() with an optional axis parameter. In the given syntax the arr_ref is the numpy array. Optional axis parameter can take the value of 1 and 0.
Following code snippet specifies the code and the result of the std function without the axis parameter.
Following code snippet specifies the result with the axis parameter with value 0 along each column.
Following code snippet specifies the result with the axis parameter with value 1 along each row.
3. var
var() function gives the variance value for the specified numpy array. The syntax for using the var function is arr_ref.var() with optional axis parameter.The syntax for var is similar to the mean and the var function.
Following code snippet specifies the code and the results for the std() function without the axis parameter.
Following code snippet specifies the code and the result for the function with axis parameter value as 0.
Following code snippet specifies the code and the result for the function with axis parameter value as 1.
Thank you.
That's all for this post!!
Thank you for reading this post.
If you have any suggestions regarding the post contents or if you need some more details on any other topic, please post it in the comments section.
Your suggestions are too valuable so they should not be missed.
References
1. https://docs.scipy.org/doc/numpy-1.15.1/reference/generated/numpy.mean.html
2. https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.std.html
3. https://docs.scipy.org/doc/numpy-1.15.1/reference/generated/numpy.var.html
var() function gives the variance value for the specified numpy array. The syntax for using the var function is arr_ref.var() with optional axis parameter.The syntax for var is similar to the mean and the var function.
Following code snippet specifies the code and the results for the std() function without the axis parameter.
Following code snippet specifies the code and the result for the function with axis parameter value as 0.
Following code snippet specifies the code and the result for the function with axis parameter value as 1.
Thank you.
That's all for this post!!
Thank you for reading this post.
If you have any suggestions regarding the post contents or if you need some more details on any other topic, please post it in the comments section.
Your suggestions are too valuable so they should not be missed.
References
1. https://docs.scipy.org/doc/numpy-1.15.1/reference/generated/numpy.mean.html
2. https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.std.html
3. https://docs.scipy.org/doc/numpy-1.15.1/reference/generated/numpy.var.html
Comments
Post a Comment