Автор: Thomas J. Sargent, John Stachurski
Издательство: QuantEcon
Год: Jun 12, 2024
Страниц: 382
Язык: английский
Формат: pdf (true)
Размер: 10.1 MB
This book presents a set of lectures on Python programming for economics and finance. This is the first text in the series, which focuses on programming in Python. Python has experienced rapid adoption in the last decade and is now one of the most popular programming languages.
Python is a general-purpose language used in almost all application domains such as:
• communications
• web development
• CGI and graphical user interfaces
• game development
• resource planning
• multimedia, data science, security, etc., etc., etc.
For reasons we will discuss, Python is particularly popular within the scientific community and behind many scientific achievements in:
• Space Science
• Particle Physics
• Genetics
and practically all branches of academia.
Meanwhile, Python is also very beginner-friendly and is found to be suitable for students learning programming and recommended to introduce computational methods to students in fields other than Computer Science. Python is also replacing familiar tools like Excel as an essential skill in the fields of finance and banking.
One nice feature of Python is its elegant syntax — we’ll see many examples later on. Elegant code might sound superfluous but in fact it’s highly beneficial because it makes the syntax easy to read and easy to remember. Remembering how to read from files, sort dictionaries and other such routine tasks means that you don’t need to break your flow in order to hunt down correct syntax. Closely related to elegant syntax is an elegant design. Features like iterators, generators, decorators and list comprehensions make Python highly expressive, allowing you to get more done with less code. Namespaces improve productivity by cutting down on bugs and syntax errors.
One obvious reason we use scientific libraries is because they implement routines we want to use. For example, it’s almost always better to use an existing routine for root finding than to write a new one from scratch. For standard algorithms, efficiency is maximized if the community can coordinate on a common set of implementations, written by experts and tuned by users to be as fast and robust as possible. But this is not the only reason that we use Python’s scientific libraries. Another is that pure Python, while flexible and elegant, is not fast. So we need libraries that are designed to accelerate execution of Python code. In terms of popularity, the big four in the world of scientific Python libraries are:
• NumPy - forms the foundations by providing a basic array data type (think of vectors and matrices) and functions
for acting on these arrays (e.g., matrix multiplication).
• SciPy - builds on NumPy by adding the kinds of numerical methods that are routinely used in science (interpolation,
optimization, root finding, etc.).
• Matplotlib - used to generate figures, with a focus on plotting data stored in NumPy arrays.
• Pandas - provides types and functions for empirical work (e.g., manipulating data).
For us, there’s another (relatively new) library that will also be essential for numerical computing:
• Numba - accelerates execution via JIT compilation.
Скачать Python Programming for Economics and Finance (Updated)