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 – comparing using maxulp of 2

Let's do the same comparisons as in the previous Time for action section, but specify a maxulp of 2 when necessary:

  1. Determine the machine epsilon with the finfo() function:
    eps = np.finfo(float).eps
    print("EPS", eps)

    The epsilon would be as follows:

    EPS 2.22044604925e-16
    
  2. Do the comparisons as done in the previous Time for action section, but use the assert_array_max_ulp() function with the appropriate maxulp value:
    print("1", np.testing.assert_array_max_ulp(1.0, 1.0 + eps))
    print("2", np.testing.assert_array_max_ulp(1.0, 1 + 2 * eps, maxulp=2))

    The output is as follows:

    1 1.0
    2 2.0
    

What just happened?

We compared the same values as the previous Time for action section, but specified a maxulp of 2 in the second comparison. Using the assert_array_max_ulp() function with the appropriate maxulp value, these tests passed with a return value of the number of ULPs.

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