Book Image

Applying Math with Python

By : Sam Morley
Book Image

Applying Math with Python

By: Sam Morley

Overview of this book

Python, one of the world's most popular programming languages, has a number of powerful packages to help you tackle complex mathematical problems in a simple and efficient way. These core capabilities help programmers pave the way for building exciting applications in various domains, such as machine learning and data science, using knowledge in the computational mathematics domain. The book teaches you how to solve problems faced in a wide variety of mathematical fields, including calculus, probability, statistics and data science, graph theory, optimization, and geometry. You'll start by developing core skills and learning about packages covered in Python’s scientific stack, including NumPy, SciPy, and Matplotlib. As you advance, you'll get to grips with more advanced topics of calculus, probability, and networks (graph theory). After you gain a solid understanding of these topics, you'll discover Python's applications in data science and statistics, forecasting, geometry, and optimization. The final chapters will take you through a collection of miscellaneous problems, including working with specific data formats and accelerating code. By the end of this book, you'll have an arsenal of practical coding solutions that can be used and modified to solve a wide range of practical problems in computational mathematics and data science.
Table of Contents (12 chapters)

How it works...

This is a very basic example of a Faust application. Ordinarily, we wouldn't generate the records and send them through the Kafka server and process them within the same app. However, this is fine for the purposes of this demonstration. In a production environment, we'd probably connect to a remote Kafka server that is connected to multiple sources and publishing to multiple different topics simultaneously.

The Faust app controls the interaction between the Python code and the Kafka server. We use the agent decorator to add a function to process information published to a particular channel. This asynchronous function will be executed each time new data is pushed to the sample topic. In this recipe, the agent that we defined simply prints the information contained within the Record objects into the terminal.

The timer decorator defines a service that regularly performs some action at a specified interval. In our case, the timer sends a...