Science Collection: Reference Manual

Science Collection
Reference Manual
Edition 4.2

October 2011

M. Douglas Williams
m.douglas.williams@gmail.com

The Science Collection is a collection of modules that provide functions for numerical computing. The structure of the science collection and many of the underlying algorithms were inspired by the GNU Scientific Library (GSL). The functions are written entirely in Racket and presents a true Racket look-and-feel throughout. The source code is distributed with the science collection and licensed under the GNU Lesser General Public License, Version 3 [LGPL].

The structure of this document and certain sections were inspired by the GNU Scientific Library – Reference Manual [GSL-RM].

© 2003-2011, M. Douglas Williams

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".

    1 Introduction

      1.1 Routines Available in the Science Collection

      1.2 The Science Collection is Free Software

      1.3 Obtaining the Science Collection

      1.4 No Warranty

    2 Using the Science Collection

      2.1 An Example

      2.2 Loading Modules in the Science Collection

      2.3 Graphics Modules

    3 Error Handling

      3.1 Contracts

        3.1.1 Fixed Number of Arguments with a Single Result

        3.1.2 Multiple Lambda Forms (case-lambda)

        3.1.3 Interparameter Constraints

        3.1.4 Unchecked Operations

      3.2 Infinities and Not-a-Number

      3.3 Exceptions

    4 Mathematical Functions

      4.1 Mathematical Constants

      4.2 Testing for Infinities and Not-a-Number

      4.3 Elementary Functions

      4.4 Testing the Sign of Numbers

      4.5 Approximate Comparisons of Real Numbers

      4.6 Log10 and Decibels (dB)

    5 Special Functions

      5.1 Error Functions

        5.1.1 Error Function

        5.1.2 Complementary Error Function

        5.1.3 Hazard Function

      5.2 Exponential Integral Functions

        5.2.1 First-Order Exponential Integral

        5.2.2 Second-Order Exponential Integral

        5.2.3 General Exponential Integral

      5.3 GammaFunctions

        5.3.1 Gamma Function

        5.3.2 Regulated Gamma Function

        5.3.3 Incomplete Gamma Function

        5.3.4 Factorial Function

        5.3.5 Double Factorial Function

        5.3.6 Binomial Coefficient Function

      5.4 Psi Functions

        5.4.1 Psi (Digamma) Functions

        5.4.2 Psi-1 (Trigamma) Functions

        5.4.3 Psi-n (Polygamma) Functions

      5.5 Zeta Functions

        5.5.1 Riemann Zeta Functions

        5.5.2 Riemann Zeta Functions Minus One

        5.5.3 Hutwitz Zeta Function

        5.5.4 Eta Functions

      5.6 Beta Functions

    6 Random Number Generation

      6.1 The SRFI 27 Specification

      6.2 Additional Random Number Functionality

        6.2.1 The current-random-source parameter

        6.2.2 Uniform Random Numbers

        6.2.3 Miscellaneous Functions

        6.2.4 Random Source Vectors

      6.3 Random Number Examples

    7 Random Number Distributions

      7.1 The Beta Distribution

        7.1.1 Random Variates from the Beta Distribution

        7.1.2 Beta Distribution Density Functions

        7.1.3 Beta Distribution Graphics

      7.2 The Bivariate Gaussian Distribution

        7.2.1 Random Variates from the Bivariate Haussian Distribution

        7.2.2 Bivariate Gaussian Distribution Density Functions

        7.2.3 Bivariate Gaussian Distribution Graphics

      7.3 The Chi-Squared Distribution

        7.3.1 Random Variates from the Chi-Squared Distribution

        7.3.2 Chi-Squared Distribution Density Functions

        7.3.3 Chi-Squared Distribution Graphics

      7.4 The Exponential Distribution

        7.4.1 Random Variates from the Exponential Distribution

        7.4.2 Exponential Distribution Density Functions

        7.4.3 Exponential Distribution Graphics

      7.5 The F-Distribution

        7.5.1 Random Variates from the F-Distribution

        7.5.2 F-Distribution Density Functions

        7.5.3 F-Distribution Graphics

      7.6 The Flat (Uniform) Distribution

        7.6.1 Random Variates from the Flat (Uniform) Distribution

        7.6.2 Flat (Uniform) Distribution Density Functions

        7.6.3 Flat (Uniform) Distribution Graphics

      7.7 The Gamma Distribution

        7.7.1 Random Variates from the Gamma Distribution

        7.7.2 Gamma Distribution Density Functions

        7.7.3 Gamma Distribution Graphics

      7.8 The Gaussian (Normal) Distribution

        7.8.1 Random Variates from the Gaussian (Normal) Distribution

        7.8.2 Gaussian (Normal) Distribution Density Functions

        7.8.3 Gaussian (Normal) Distribution Graphics

      7.9 The Gaussian Tail Distribution

        7.9.1 Random Variates from the Gaussian Tail Distribution

        7.9.2 Gaussian Tail Distribution Density Functions

        7.9.3 Gaussian Tail Distribution Graphics

      7.10 The Log Normal Distribution

        7.10.1 Random Variates from the Log Normal Distribution

        7.10.2 Log Normal Distribution Density Functions

        7.10.3 Log Normal Distribution Graphics

      7.11 The Pareto Distribution

        7.11.1 Random Variates from the Pareto Distribution

        7.11.2 Pareto Distribution Density Functions

        7.11.3 Pareto Distribution Graphics

      7.12 The t-Distribution

        7.12.1 Random Variates from the t-Distribution

        7.12.2 t-Distribution Density Functions

        7.12.3 t-Distribution Graphics

      7.13 The Triangular Distribution

        7.13.1 Random Variates from the Triangular Distribution

        7.13.2 Triangular Distribution Density Functions

        7.13.3 Triangular Distribution Graphics

      7.14 The Bernoulli Distribution

        7.14.1 Random Variates from the Bernoulli Distribution

        7.14.2 Bernoulli Distribution Density Functions

        7.14.3 Bernoulli Distribution Graphics

      7.15 The Binomial Distribution

        7.15.1 Random Variates from the Binomial Distribution

        7.15.2 Binomial Distribution Density Functions

        7.15.3 Binomial Distribution Graphics

      7.16 The Geometric Distribution

        7.16.1 Random Variates from the Geometric Distribution

        7.16.2 Geometric Distribution Density Functions

        7.16.3 Geometric Distribution Graphics

      7.17 The Logarithmic Distribution

        7.17.1 Random Variates from the Logarithmic Distribution

        7.17.2 Logarithmic Distribution Density Functions

        7.17.3 Logarithmic Distribution Graphics

      7.18 The Poisson Distribution

        7.18.1 Random Variates from the Poisson Distribution

        7.18.2 Poisson Distribution Density Functions

        7.18.3 Poisson Distribution Graphics

      7.19 General Discrete Distributions

        7.19.1 Creating Discrete Distributions

        7.19.2 Random Variates from a Discrete Distribution

        7.19.3 Discrete Distribution Density Functions

        7.19.4 Discrete Distribution Graphics

    8 Statistics

      8.1 Running Statistics

      8.2 Running Statistics Example

      8.3 Mean, Standard Deviation, and Variance

      8.4 Absolute Deviation

      8.5 Higher Moments (Skewness and Kurtosis)

      8.6 Autocorrelation

      8.7 Covariance

      8.8 Correlation

      8.9 Weighted Samples

      8.10 Maximum and Minimum

      8.11 Median and Quantiles

      8.12 Statistics Example

    9 Histograms

      9.1 Histograms

        9.1.1 Creating Histograms

        9.1.2 Updating and Accessing Histogram Elements

        9.1.3 Histogram Statistics

        9.1.4 Histogram Graphics

        9.1.5 Histogram Examples

      9.2 2D Histograms

        9.2.1 Creating 2D Histograms

        9.2.2 Updating and Accessing 2D Histogram Elements

        9.2.3 2D Histogram Statistics

        9.2.4 2D Histogram Graphics

        9.2.5 2D Histogram Examples

      9.3 Discrete Histograms

        9.3.1 Creating Discrete Histograms

        9.3.2 Updating and Accessing Discrete Histogram Elements

        9.3.3 Discrete Histogram Statistics

        9.3.4 Discrete Histogram Graphics

        9.3.5 Discrete Histogram Examples

    10 Ordinary Differential Equations

      10.1 Defining the ODE System

        10.1.1 Stepping Functions

      10.2 Adaptive Step-Size Control

      10.3 Evolution

      10.4 ODE Examples

    11 Chebyshev Approximations

      11.1 The chebyshev-series Structure

      11.2 Creation and Calculation of Chebyshev Series

      11.3 Chebyshev Series Evaluations

      11.4 Derivatives and Integrals

      11.5 Chebyshev Approximation Examples

    12 Fast Fourier Transforms

      12.1 Radix-2 FFT Routines

      12.2 Mixed-Radix FFT Routines

      12.3 FFT Examples

        12.3.1 Radix 2 FFT Example

        12.3.2 Mixed-Radix FFT Example

    13 Physical Constants

      13.1 Fundamental Constants

      13.2 Astronomy and Astrophysics

      13.3 Atomic and Nuclear Physics

      13.4 Measurements of Time

      13.5 Imperial Units

      13.6 Speed and Nautical Units

      13.7 Printers Units

      13.8 Volume, Area and Length

      13.9 Mass and Weight

      13.10 Thermal Energy and Power

      13.11 Pressure

      13.12 Viscosity

      13.13 Light and Illumination

      13.14 Radioactivity

      13.15 Force and Energy

      13.16 Prefixes

      13.17 Physical Constants Example

    14 Unsafe Operations Utilities

    15 GNU Free Documentation License

    Bibliography

    Index