Alan Miller's Fortran Software

[ Subset Selection | Random Number Generation | Quad Precision | Applied Statistics Algorithms | Logistic Regression | TOMS Algorithms | Naval Surface Warfare Center Code | Miscellaneous | 10-Byte Reals for NAS FortranPlus | F code | Linear Least Squares | Links ]

This is an archived copy of the Fortran source code repository of Alan Miller previously located at It is hosted by Jason Blevins with permission. The site has been slightly reformatted, but the source code and descriptions below have not been modified.

All code written by Alan Miller is released into the public domain. Code written by other authors or from other sources (e.g., academic journals) may be subject to other restrictions.

Subset Selection in Regression

The 2nd edition of my book on this subject was published by CRC Press (Chapman & Hall) in April 2002 (ISBN 1-58488-171-2). Dr. David Smith from the Medical College of Georgia, USA, has notified me of certain missing references. Here they are in postscript and pdf formats.

As I can no longer access my ozemail web site, I shall make the latest versions of my subsets software available here.

For subset selection using the L1-norm, that is minimizing the sum of absolute residuals, here is toms615.f90 which is a translation of TOMS algorithm 615 to make it ELF90 compatible. There is also a driver program test615.f90, some test data test615.dat, and the expected output test615.out.

For linear regression, but when the regression coefficients must be positive or zero, there is the Lawson & Hanson non-negative least-squares routine nnls.f90. N.B. Two call arguments have been removed from the Fortran 77 version. This routine is ELF90-compatible.

I have also added my own nonnegls.f90 routine which is called after a QR-factorization has been formed using module LSQ. The file t_nnls.f90 uses both of these routines.

Back to top

Uniform Random Number Generation

Back to top

Random numbers from other distributions

Back to top

Quadruple precision

There are multiple-precision (MP) software packages available when double precision is not adequate, but these are extremely slow. Quadruple precision gives about twice as many accurate digits as double precision and is much faster than MP.

I am indebted to Keith Briggs (previouly at University of Cambridge) for access to his package in C++ for quadruple precision which helped improve the algorithm for calculating exponentials.

There is a newer package for double-double precision and quad-double precision (about 64 decimal digits accuracy) in C++, which has a Fortran front-end, at Click here.

Back to top

Some Applied Statistics Algorithms

For many years, the Royal Statistical Society published algorithms in its journal `Applied Statistics'. I have translated a few of these to F90.

Back to top

Logistic Regression

I have received several requests for Fortran code to perform logistic regression, that is to fit:

p = F/(1 + F)
p = the probability that a case is in one of two categories
F = exp(b0 + b1.X1 + b2.X2 + ... + bk.Xk)
X1, X2, ..., Xk is a set of k predictors, and
b0, b1, b2, ..., bk is a set of coefficients to be fitted.

Back to top

Miscellaneous TOMS (and CACM) algorithms

N.B. I have been asked to provide a link to the copyright policy of the ACM. Loosely paraphrased, this allows use, and modification, of the TOMS algorithms for most non-commercial purposes. It also emphasizes that the ACM accepts no responsibility for the accuracy of the code.

I have updated some of the Transactions on Mathematical Software (TOMS) algorithms to Fortran 90.

Back to top

Code converted from the
Naval Surface Warfare Center Math. Library

Back to top

Miscellaneous code

Back to top

10-byte REAL code for NAS FortranPlus

This exploits the 10-byte REAL data type which is supported by this compiler. At the moment, it only contains a special version of my quadruple precision package which gives about 38 decimal digit representation of quadruple precision numbers. N.B. It is extremely unlikely that this will give correct answers with any other compiler (e.g. Salford) which supports 10-byte REALs.

Back to top

Code for Imagine1's F compiler

Quadruple Precision Code

Other code for F

Back to top

Some linear least-squares examples and tests

Back to top

Try the Fortran Market for general information on Fortran compilers, tutorials, books and access to some sources of Fortran code, Gary Scott's Fortran Library web site.
The Fortran90 FAQ (frequently asked questions) can be obtained from: F90FAQ.
For an extensive set of routines for sorting and ranking real numbers see OrderPack.
NAG F90 Software Repository is a source of useful Fortran 90 code.
The ACM collection of TOMS algorithms is a source of refereed code, mainly in Fortran, for a wide range of numerical calculations.
A collection of functions and subroutines covering a wide area of mathematical
John Monahan's site contains the software from his book `Numerical Methods of Statistics'. It covers a very similar are to this web site, and is at: Monahan's web site. operations can be found at Jean-Pierre Moreau's web site.
For a guide to available mathematical software, refer to GAMS, and for the numerical analysis FAQ numafaq.
If you are interested in object-oriented programming in Fortran, you should see oof90.html.
For statistical software in a variety of languages try statlib. For distribution functions, random number generation and other statistical programs, try cdflib/ranlib.
For optimization, particularly constrained optimization, see the Optimization Decision Tree, or Arnold Neumaier's Global Optimization web site. The latter also contains many general links to mathematical and statistical software.
For multivariate normal integrals, and for multiple integration in general, look at Alan Genz's home page.
Michel Olagnon's ORDERPACK is for sorting and ranking. It can be found at: ORDERPACK.
Australian Fortran users will find the web page of Computer Transition Systems useful. (This company distributes Lahey, Salford, Edinburgh Portable Compilers, Digital Visual Fortran and other compilers in Australia.)
To download Lahey's cheap Fortran 90 compiler click on ELF90.

There is an interpreter for a subset of Fortran 90 available from: Georg Petrich's interpreter. I have not tried it myself, so comments would be welcome. It can be downloaded freely, but I understand it is a shareware product.
For a wide range of code for the FFT, in several computer languages, see: The FFT Home Page. and: Another FFT Home Page.


Back to top