GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - numericalalgorithmsgroup/NAGPythonExamples: Examples and demos showing how to call functions from the nAG Library for Python

BranchesTags
Open more actions menu

Latest commit

 

History

407 Commits
407 Commits

Folders and files

NameName
Last commit message
Last commit date
correlation_and_regression_analysis
correlation_and_regression_analysis
 
 
curve_and_surface_fitting
curve_and_surface_fitting
 
 
dimension_reduction
dimension_reduction
 
 
global_optimization
global_optimization
 
 
linear_algebra
linear_algebra
 
 
local_optimization
local_optimization
 
 
multivariate_methods
multivariate_methods
 
 
nearest_correlation_matrices
nearest_correlation_matrices
 
 
operations_research
operations_research
 
 
random_number_generation
random_number_generation
 
 
roots
roots
 
 
special_functions
special_functions
 
 
time_series_analysis
time_series_analysis
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
Mark_27_examples.md
Mark_27_examples.md
 
 
README.md
README.md
 
 
_config.yml
_config.yml
 
 
nag_logo.png
nag_logo.png
 
 

Repository files navigation

nAG Logo

Content

  • Examples using the nAG Library for Python
  • How to install the nAG Library for Python
  • How to run the Jupyter notebook examples
  • List of Chapters in the nAG Library for Python
  • Useful links

Examples using the nAG Library for Python

This repository contains examples and demonstrations using the nAG Library for Python. The nAG Library for Python contains 1900+ functions spanning many areas of numerical computing and data science.

Designed to work alongside the open source Python packages, Numpy and Scipy, The nAG Library for Python can augment your computational workflow in many areas.

Directory of GitHub examples

  • Correlation and regression analysis
  • Curve and surface fitting
  • Dimensionality Reduction
  • Global Optimization
  • Linear Algebra
  • Local optimization
  • Multivariate methods
  • Nearest Correlation Matrices
  • Operations Research
  • Random number generation
  • Roots
  • Time series analysis

Examples that ship with the product

In addition to those presented here, The nAG Library for Python ships with a set of usage examples. To see them all, run the following command

python -m naginterfaces.library.examples --locate

How to install the nAG Library for Python

In this section we illustrate how to install the nAG Library for Python, request a Trial Licence and make sure the Library is working. Details and further information regarding the installation can be found here.

Note Before starting make sure you have access to a host that has Python 3 (3.4 or more recent).

Step 1. Downloading and installing

Installing the nAG Library is done using the pip package manager, fire-up a terminal and create a Python 3 virtual environment where to install and test the nAG Library

guest@nag-37:~$ python3 -m venv nag3
guest@nag-37:~$ . nag3/bin/activate
(nag3) guest@nag-37:~$

Now use pip to install the nAG Library for Python

(nag3) guest@nag-37:~$ python -m pip install --extra-index-url https://www.nag.com/downloads/py/naginterfaces_nag naginterfaces

or if you prefer the version of the package that relies on Intel MKL for optimized linear algebra routines, then use

(nag3) guest@nag-37:~$ python -m pip install --extra-index-url https://www.nag.com/downloads/py/naginterfaces_mkl naginterfaces

The output should be similar to

Collecting naginterfaces
  Downloading https://www.nag.com/downloads/py/naginterfaces_nag/naginterfaces/naginterfaces-27.1.0.0-py2.py3-none-linux_x86_64.whl (55.8MB)
    100% |████████████████████████████████| 55.8MB 21kB/s 
Collecting numpy>=1.15 (from naginterfaces)
  Downloading https://files.pythonhosted.org/packages/45/b2/6c7545bb7a38754d63048c7696804a0d947328125d81bf12beaa692c3ae3/numpy-1.19.5-cp36-cp36m-manylinux1_x86_64.whl (13.4MB)
    100% |████████████████████████████████| 13.4MB 70kB/s 
Installing collected packages: numpy, naginterfaces
Successfully installed naginterfaces-27.1.0.0 numpy-1.19.5

The output indicates that the installation was successful.

Step 2. Getting a trial licence

The next step is to get the licensing info (product code and KUSARI ID) and use it to request a licence. From the same virtual terminal, try

(nag3) guest@nag-37:~$ python -m naginterfaces.kusari

The output should be similar to

The *n*AG Library for Python on this platform uses
underlying Library NLL6I271VL.
This Library has been installed as part of the package
and it requires a valid licence key.
No such key could be validated:
the key may not have been installed correctly or
it may have expired.
The Kusari licence-check utility reports the following:
User: guest
Directory: /home/guest
NAG_KUSARI_FILE=""
File /home/guest/nag.key does not exist
-------------------------------------------------------------------------------
Error: Licence not found; this product requires a key for NLL6I271VL
The above information has been generated on machine nag-37
For information on how to obtain a licence, please see
https://www.nag.com/numeric/py/nagdoc_latest/naginterfaces.kusari.html
KUSARI ID = "ADLXt-adEclJLmvnxlrU2sseteZoo,RopA-Ld"

The two important bits are the

  1. product code shown as underlying Library NLL6I271VL. which identifies the licence to request, and

  2. KUSARI ID shown as KUSARI ID = "ADLXt-adEclJLmvnxlrU2sseteZoo,RopA-Ld" which identifies the host you are running the library on.

Note that the product code and KUSARI ID can be different from the previous example.

With these, you are set to contact nAG and request a trial licence.

The trial licence is a plain text chunk similar to

NLL6I271V TRIAL 2021/01/27 "RverXn0Pc-Ib?ctdgF=Wpis2j7I"

Save or copy the text into the file /home/guest/nag.key.

The final step is to make sure the licence is valid and the library is working as expected.

Step 3. Testing the nAG Library

The last step is to make sure the licence was correctly stored and that the nAG Library is working correctly. From the same virtual terminal re-run the Kusari licence module

(nag3) guest@nag-37:~$ python -m naginterfaces.kusari

This time the output should be similar to

Licence available; the required NLL6I271VL licence key for this product is valid
TRIAL licence, 27 days remaining (licence from file)

Now let's try a more interesting example (list of optimization examples)

This command runs the example for the FOAS (First-Order Active set method) solver and minimizes the Rosenbrock 2D function.

(nag3) guest@nag-37:~$ python -m naginterfaces.library.examples.opt.handle_solve_bounds_foas_ex

Should generate an outputsimilar to

Trying:
    main()
Expecting:
    naginterfaces.library.opt.handle_solve_bounds_foas Python Example Results.
    Minimizing a bound-constrained Rosenbrock problem.
     E04KF, First order method for bound-constrained problems
...
     Status: converged, an optimal solution was found
     Value of the objective             4.00000E-02
    ...
ok

indicating that the example was successfully executed. The source code can be found here.

Running more examples

To display the full list of example source files on disk, but not run them, execute

python -m naginterfaces.library.examples --locate

All examples may be executed sequentially by running

python -m naginterfaces.library.examples

Run python -m naginterfaces.library.examples --help to see any additional usage.

How to run the Jupyter notebook examples

This section briefly illustrates how to setup a host in order to open and run the Jupyter notebooks provided in this repository. Before running the notebooks make sure the nAG Library is installed and working. Before starting, it is advised to read Jupyter's installation page.

Installing Jupyter notebook

To install Jupyter, launch a terminal and activate the virtual environment used to install the nAG Library for Python

guest@nag-37:~$ . nag3/bin/activate
(nag3) guest@nag-37:~$ pip install notebook matplotlib
Collecting notebook
  Downloading https://files.pythonhosted.org/packages/74/19/50cd38acf22e33370d01fef764355f1e3517f6e12b4fceb8d434ece4f8fd/notebook-6.2.0-py3-none-any.whl (9.5MB)
    100% |████████████████████████████████| 9.5MB 115kB/s 
Collecting argon2-cffi (from notebook)
...
Successfully installed jupyter-client-6.1.11 jupyterlab-pygments-0.1.2 ... wcwidth-0.2.5

This indicates that Jupyter and matplotlib were successfully installed. The next section shows how to start the notebok interface and open an example.

Running the notebook examples

To run an example, grab a copy of the notebook of interest and start up the notebook interface. For example, download the Rosenbrock 2D optimization example notebook rosenbrock2d.ipynb into the current directory

(nag3) guest@nag-37:~$ curl -O https://raw.githubusercontent.com/numericalalgorithmsgroup/NAGPythonExamples/master/local_optimization/FOAS/rosenbrock2d.ipynb
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 61961  100 61961    0     0   382k      0 --:--:-- --:--:-- --:--:--  382k

and now open it using jupyter-notebook

(nag3) guest@nag-37:~$ jupyter-notebook rosenbrock2d.ipynb
[I 12:24:07.336 NotebookApp] Serving notebooks from local directory: /home/guest
[I 12:24:07.336 NotebookApp] Jupyter Notebook 6.2.0 is running at:
[I 12:24:07.336 NotebookApp] http://localhost:8888/?token=f1836a06799a92f25ef9966439bf3491b2f0960dcb51806d
...

This command will fire-up your web browser and open the rosenbrock2d.ipynb notebook, the window should be similar to

Notebook screenshot

List of Chapters in the nAG Library for Python

The following links take you to the relevant section in the official documentation

  • library.anova - Analysis of Variance
  • library.blas - Linear Algebra Support Routines
  • library.blast - Further Linear Algebra Support Routines
  • library.blgm - Linear Model Specification
  • library.complex - Complex Arithmetic
  • library.contab - Contingency Table Analysis
  • library.correg - Correlation and Regression Analysis
  • library.det - Determinants
  • library.dot - Inner Products
  • library.eigen - Eigenvalues and Eigenvectors
  • library.fit - Curve and Surface Fitting
  • library.glopt - Global Optimization of a Function
  • library.ieee - IEEE Arithmetic
  • library.info - Library Identification
  • library.inteq - Integral Equations
  • library.interp - Interpolation
  • library.lapackeig - Least Squares and Eigenvalue Problems
  • library.lapacklin - Linear Equations
  • library.linsys - Simultaneous Linear Equations
  • library.machine - Machine Constants
  • library.math - Mathematical Constants
  • library.matop - Matrix Operations, Including Inversion
  • library.mesh - Mesh Generation
  • library.mip - Operations Research
  • library.mv - Multivariate Methods
  • library.nonpar - Nonparametric Statistics
  • library.numdiff - Numerical Differentiation
  • library.ode - Ordinary Differential Equations
  • library.omp - OpenMP Utilities
  • library.opt - Minimizing or Maximizing a Function
  • library.orthog - Orthogonalization
  • library.pde - Partial Differential Equations
  • library.quad - Quadrature
  • library.rand - Random Number Generators
  • library.rnla - Randomized Numerical Linear Algebra
  • library.roots - Roots of One or More Transcendental Equations
  • library.smooth - Smoothing in Statistics
  • library.sort - Sorting and Searching
  • library.sparse - Large Scale Linear Systems
  • library.sparseig - Large Scale Eigenproblems
  • library.specfun - Approximations of Special Functions
  • library.stat - Simple Calculations on Statistical Data
  • library.sum - Summation of Series
  • library.surviv - Survival Analysis
  • library.tsa - Time Series Analysis
  • library.univar - Univariate Estimation
  • library.wav - Wavelet Transforms
  • library.zeros - Zeros of Polynomials

Useful links

  • nAG Library for Python Documentation
  • Kusari licence module Documentation

Back to Top

About

Examples and demos showing how to call functions from the nAG Library for Python

Topics

correlation-matrixcurve-fittingjupyter-notebookslinear-algebranag-librarynonlinear-optimizationnumerical-methodsoptimizationpythonquantitative-financerandom-number-generatorsroot-findingscientific-computingsurface-fittingtime-series-analysistrial

Resources

Readme
BSD-3-Clause license
Activity
Custom properties

Stars

70 stars

Watchers

11 watching

Forks

27 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.