Chapter 5. Numerical Computing with NumPy
Computers are useless. They can only give answers.
Pablo Picasso
Numerical computing is at the core of quantitative finance workflows: pricing, risk, backtesting, and simulation all rely on fast operations over large arrays of numbers. This chapter introduces NumPy, the array-based numerical foundation that underpins later chapters on pandas, time series, simulation, and machine learning.
The chapter shows how to work with NumPy arrays (ndarray objects) for fast numerical
computing. It explains how NumPy arrays differ from Python lists, how to create and
inspect arrays, how to reshape and aggregate them, how to express computations with
vectorization and broadcasting, how to use Boolean masks and np.where, and how to
generate random numbers with numpy.random’s modern Generator interface.
To follow along, you need a working python 3.11+ interpreter with numpy installed
(see Chapter 3), an interactive environment such as
IPython or Jupyter, and familiarity ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access