Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Numpy Beginner's Guide (Update)
  • Toc
  • feedback
Numpy Beginner's Guide (Update)

Numpy Beginner's Guide (Update)

By : Ivan Idris
2 (1)
close
Numpy Beginner's Guide (Update)

Numpy Beginner's Guide (Update)

2 (1)
By: Ivan Idris

Overview of this book

This book is for the scientists, engineers, programmers, or analysts looking for a high-quality, open source mathematical library. Knowledge of Python is assumed. Also, some affinity, or at least interest, in mathematics and statistics is required. However, I have provided brief explanations and pointers to learning resources.
Table of Contents (16 chapters)
close
14
C. NumPy Functions' References
15
Index

Time for action – applying the ufunc methods to the add function

Let's call the first four methods on the add() function:

  1. The universal function reduces the input array recursively along a specified axis on consecutive elements. For the add() function, the result of reducing is similar to calculating the sum of an array. Call the reduce() method:
    a = np.arange(9)
    print("Reduce", np.add.reduce(a))

    The reduced array should be as follows:

    Reduce 36
    
  2. The accumulate() method also recursively goes through the input array. But, contrary to the reduce() method, it stores the intermediate results in an array and returns that. The result, in the case of the add() function, is equivalent to calling the cumsum() function. Call the accumulate() method on the add() function:
    print("Accumulate", np.add.accumulate(a))

    The accumulated array is as follows:

    Accumulate [ 0  1  3  6 10 15 21 28 36]
    
  3. The reduceat() method is a bit complicated to explain, so let's call it and go through...
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete