Applied Numerical Methods with Python and Python
Libraries (code Python)
Module 1 Essential Python Language Advanced Functional Programming
Overview/review of how to create functions, Applications of filter ()
modules and classes that use numerical algorithms Generator expressions
and related data structures. Recursion and reduction
Creating Classes in Python Folds
Naming conventions Iterables
My first class A-Z
Constructors and initialisation Universal Functions
Creating objects and class instantiation Creating vectorised wrappers
Access control issues Handling floating-point errors and callbacks
How Python implements the IEEE 754 standard
Creating Larger Classes Casting rules
Composition and Delegation Universal function’ methods (for example, reduce,
Whole-part objects in Python accumulate)
Arrays and collections of objects Math operations
Inheritance and subclassing
Combining inheritance and composition Exception Handling in Python Programs
Raising exceptions
Fundamental Arrays and Data Structures Handling exceptions
Basic data types Exception hierarchy and built-in exceptions
One-dimensional arrays; matrices User-defined exceptions
n-dimensional arrays (ndarray)
Data type objects (dtype) Module 3 Essential Mathematical Structures
Tuples, dictionaries and lists Approximation of functions by polynomials is
probably one of the most important activities in
Modules and Packages numerical analysis and its applications. To this end,
Organising your classes we show how Python supports these activities. We
Creating modules and accessing their contents also introduce univariate discrete and continuous
Nested modules and packages statistical distributions as well as random number
Absolute and relative imports generators.
Module 2 Functional Programming in Python Polynomials
An introduction to functional programming and a 1d, 2d and 3d polynomials
discussion with easy-to-understand examples in The algebra of polynomials
numerical computation and its applications. In Power series polynomials
particular, universal functions play a central role. Operations on polynomials
We also show how to write code that is a mix of
the object-oriented and functional programming Special Polynomials and Functionality
styles. Orthogonal polynomials: Chebychev, Legendre,
Laguerre, Hermite
Introduction to Higher-order Functions (HOFs) 1d, 2d and 3d orthogonal polynomial grids
Least Squares fitting
What can we do with HOFs?
Spline fitting
Simplify HOFs by lambda forms and lambda
expressions
Lambdas and the lambda calculus Random Sampling
Apply a function to a collection: map () Simple random data
Pass/reject data with filter () Permuting and shuffling randomly
1
Continuous and discrete distributions Mathematical Functions
Drawing random samples Trigonometric and inverse trigonometric functions
Creating histograms Rounding
Sums, products and differences
Arrays Exponential and logarithmic functions
N-dimensional arrays ndarray
Creating and manipulating arrays Linear Algebra: Overview
Iterating over arrays ATLAS LAPACK and BLAS libraries
Applications Basic routines
Computing norms
Module 4 Fundamental Numerical Methods LU and Cholesky decomposition
This module introduces several important libraries
that are needed in many kinds of applications and Advanced Linear Algebra
that we use in later modules. Eigenvalue and eigenvector computation
Decomposition: QR, Schur, SVD (Singular Value
Integration Decomposition)
General purpose integration schemes in one, two, Matrix functions (for example, the exponential of a
three and n dimensions matrix)
Gaussian and Romberg integration Special matrices
Trapezoid and Simpson’s rules
Gaussian quadrature roots of orthogonal Matrix Library ([Link] )
polynomials Matrix objects
Creating and initializing matrices
Numerical Solution of Ordinary Differential Using matrices in applications
Equations (ODE, odeint)
Real-valued and complex-valued ODEs Interpolation
First-order and higher-order ODEs Overview of univariate and multivariate
Application areas interpolation
Interpolating a 1-d function
Statistics Piecewise polynomial interpolation
Random variables Piecewise linear interpolation in N dimensions
Probability and cumulative distribution functions Interpolation over a 2-d grid
T-test, Kolmogorov-Smirnov test 2d splines
Test for normality
Comparing two samples Module 6 Numerical Solution of Ordinary and
Estimation Partial Differential Equations (ODE/PDE)
Kernel density estimation (KDE) This module introduces modern finite difference
Univariate and multivariate estimation (FDM) schemes that approximate the solution of
Applications time-dependent partial differential equations, in
particular, parabolic PDEs. It prepares the way for
An Introduction to Optimisation work on computational finance that we discuss in
Univariate minimisers and root finders Module 7.
Unconstrained and constrained multivariate
optimization Automatic Differentiation (AD) Packages
Least squares minimization and curve fitting What is AD?
Orthogonal distance regression (ODR) Using AD to compute gradient, Jacobian and
Hessian
Module 5 Advanced Numerical Methods Examples: Optimisation and ODE solvers
This module is central to all computationally- Application to sensitivity analysis and Machine
intensive applications because it discusses Learning (ML)
numerical linear algebra which consists of routines
to solve matrix equations, eigenvalue and Solving ODEs Numerically
eigenvector computation as well as matrix Hand-crafted solutions versus
decomposition methods based on LAPACK and [Link]
Scalar equations and systems of equations
Matlab. We also discuss interpolation algorithms
Stiff and non-stiff problems
in one and two dimensions.
Using [Link]
2
Some Important Finite Difference Schemes Early exercise and Brennan-Schwartz condition
Explicit Euler, fully implicit
Crank Nicolson FDM, Part II
Alternating Direction Explicit (ADE) FDM for interest rate problems
Methods of Lines (MOL) using Method of Lines (MOL)
[Link] Cox-Ingersoll Ross (CIR) PDE/FDM
Feller condition
Model PDE: the one-Dimensional Heat Equation Callable bond PDE/FDM
PDE formulation (initial boundary value problem)
Finite difference methods for the heat equation Module 8 An Introduction to Machine Learning
Using Python libraries (ML)
Creating a working program in Python This module is a gentle introduction to ML, mainly
centered around ready-made Python libraries for
Implementing Convection-Diffusion-Reaction clustering and training.
(CDR) Equations
What is CDR? Background
Numerical approximation High-Level Overview of ML
Examples and applications Essential underlying numerical methods
Application areas
Module 7 Python for Computational Finance Python for ML
In this module we introduce FDM, lattice and
Monte Carlo (MC) methods to price financial Training Models
derivatives containing state-of-the-art algorithms. Linear regression
The design was first implemented in C++ (by the Gradient descent and its variants (e.g. SGD)
originator of this course) and then ported to Polynomial regression
Python. This is a quick-start way to learn Learning curves
computational finance with the least effort. Logistic regression
Option Pricing Analytical Solutions Clustering
The Black-Scholes option pricing formula An introduction to vector quantisation
Put-call parity An introduction to k-means clustering
Black Scholes greeks (delta, vega, theta, gamma..) Clustering package
Analytical formulae for American options Hierarchical clustering
Trees and Binomial Method Module 9 Auxiliary Libraries
The binomial formula This module consists of several utility libraries for
Creating a lattice data structure serialisation, multi-dimensional data, date time
Cox-Ross-Rubinstein (CRR) and American options functions and producing machine code.
Binomial methods and greeks
Input and Output Essentials
Monte Carlo Simulation Load and save MATLAB files
Valuation by simulation Birds’-eye overview of HDF5
Antithetic variates and variance reduction Dictionary of numpy arrays
Multiple stochastic factors Working with NetCDF files
Examples: Arithmetic and Geometric Asian options Examples and applications
Numerical Approximation of Stochastic Python with HDF5
Differential Equations (SDE) HDF5 tools
What is an SDE? Reading and writing data
Exact simulation Working with datasets
Euler-Maruyama method Chunking and compression
Generating paths
Modified predictor-corrector method Financial Functions
Future and (net) present values
The Finite Difference Method (FDM), first Computing payments
Principles Internal Rate of Return (IRR)
The one-factor Black Scholes PDE: preprocessing Interest rate computation
ADE, fully implicit and Crank Nicolson methods
Computing option sensitivities
3
Datetime Support Functions Behavioural Patterns
Business day functions Mediator
Valid business days Command
Rolling Strategy and Template Method
Number of days between two dates Visitor
Advanced Statistical Functions Your Trainer
Overview of (extensive) functions and their Daniel J. Duffy started the company Datasim in
applications 1987 to promote C++ as a new object-oriented
Chi-square test language for developing applications in the roles of
Kruskal-Wallis developer, architect and requirements analyst to
Kolmogorov-Smirnov
help clients design and analyse software systems
Calculating regression line
for Computer Aided Design (CAD), process control
Geometric and harmonics means
and hardware-software systems, logistics,
holography (optical technology) and
Pandas (Data Analysis)
Data science tools in Python
computational finance. He used a combination of
Data analysis workflow: DataFrame object Working top-down functional decomposition and bottom-
with data operations Time series functionality up object-oriented programming techniques to
create stable and extendible applications (for a
JIT and fast Machine Code discussion, see Duffy 2004 where we have
Introduction to Numba grouped applications into domain categories).
Decorating Python code Previous to Datasim he worked on engineering
When to use Numba applications in oil and gas and semiconductor
industries using a range of numerical methods (for
Module 10 Putting it all together: Structuring example, the finite element method (FEM)) on
your Applications mainframe and mini-computers.
We have included this module to create an Daniel Duffy has BA (Mod), MSc and PhD degrees
awareness of methods and design patterns to help in pure and applied mathematics and has been
the software developer create maintainable and active in promoting partial differential equation
extendible code. This is needs when software (PDE) and finite difference methods (FDM) for
systems begin to mature and extended after initial applications in computational finance. He was
software prototypes have been created. responsible for the introduction of the Fractional
Step (Soviet Splitting) method and the Alternating
Big Picture Direction Explicit (ADE) method in computational
Context diagram and data flow finance. He is also the originator of the exponential
System Decomposition fitting method for time-dependent partial
Finding modules and classes differential equations.
Creating a software prototype He is also the originator of two very popular C++
Testing and debugging code online courses (both C++98 and C++11/14) on
[Link] in cooperation with Quantnet
An Introduction to Design Patterns LLC and Baruch College (CUNY), NYC. He also trains
What, why, when and how Design Patterns developers and designers around the world. He
Creational, structural and behavioural patterns
can be contacted dduffy@[Link] for queries,
Discovering patterns in your applications
information and course venues, in-company
The top 7 design patterns
course and course dates
Creational Patterns
Factory Method
Abstract Factory
Builder
Structural Patterns
Adapter
Façade
Decorator
Bridge