NumPy Tutorial · NumPy ufunc
ufunc Summations
Learn all about ufunc Summations in this comprehensive tutorial.
5 min read advanced
- •What is the difference between summation and addition?
- •If you specify axis=1, NumPy will sum the numbers in each array.
- •Cummulative sum means partially adding the elements in array.
Summations
What is the difference between summation and addition?
Addition is done between two arguments whereas summation happens over n elements.
python
Note: Returns: [2 4 6]
python
Note: Returns: 12
Summation Over an Axis
If you specify axis=1, NumPy will sum the numbers in each array.
python
Note: Returns: [6 6]
Cummulative Sum
Cummulative sum means partially adding the elements in array.
E.g. The partial sum of [1, 2, 3, 4] would be [1, 1+2, 1+2+3, 1+2+3+4] = [1, 3, 6, 10].
Perfom partial sum with the cumsum() function.
python
Note: Returns: [1 3 6]
Module quiz
2 questions1
Which of the following is true about ufunc Summations?
2
What is the most common pitfall when working with ufunc Summations?
Answer all questions to submit.