NumPy Tutorial · NumPy ufunc
ufunc Differences
Learn all about ufunc Differences in this comprehensive tutorial.
5 min read advanced
- •A discrete difference means subtracting two successive elements.
Differences
A discrete difference means subtracting two successive elements.
E.g. for [1, 2, 3, 4], the discrete difference would be [2-1, 3-2, 4-3] = [1, 1, 1]
To find the discrete difference, use the diff() function.
python
Note: Returns: [5 10 -20] because 15-10=5, 25-15=10, and 5-25=-20
We can perform this operation repeatedly by giving parameter n.
python
Note: Returns: [5 -30] because: 15-10=5, 25-15=10, and 5-25=-20 AND 10-5=5 and -20-10=-30
Module quiz
2 questions1
Which of the following is true about ufunc Differences?
2
What is the most common pitfall when working with ufunc Differences?
Answer all questions to submit.