Delphi Math Functions

Statistics and Probability

Contents

 Statistics Functions Probability Functions Curve Fitting, Regression, Least Squares, Data Modeling Sources Key Links

Statistics Functions

Numerical Methods in Pascal page
http://www-rab.larc.nasa.gov/nmp/nmpIndex.htm#Statistics

Probability Functions

Numerical Methods in Pascal page
http://www-rab.larc.nasa.gov/nmp/nmpIndex.htm#RandomNumbers

 Function Name Description Source(s) beta betai beta function, incomplete beta function recipes bico binomial coefficients recipes BinCL Confidence limit for binomial probability parameter StatUnit(distr) Binomial binomial coefficients, C(N, K) TPmath1(fmath) BinomialCoeff binomial coefficients ESBMaths bnldev binomial distributed random deviates recipes ChiSqrTest Buxbaum(circularbib) chsone, chstwo Chi squred probability recipes recipes expdev exponential random deviates recipes Fact factorial = n! = n*(n-1)*(n-2)* ...*3*2*1 TPmath1(fmath) Factorial Turbo (p. 142) Factorials "Big Factorials" program www.delphiforfun.org/Programs/big_factorials.htm FactorialX ESBMaths factrl factln factorial, logarithm of factorial recipes FTest Buxbaum(circularbib) gamdev gamma-law distribution random deviates recipes gamma gamma function TPmath1(fmath), mathe, Turbo (p. 142) gammp gammq gammln gamma function gamma(z + 1) = z * gamma(z) = z!incomplete gamma function (gammp) incomplete, complement (gammq) logarithm of gamma function (gammln) recipes gasdev normally distributed random deviates recipes GaussIntegral Buxbaum(statbib) Gaussian Random Numbers TPmath2(RanGaus) IntegralChi Buxbaum(statbib) Integral_F Buxbaum(statbib) Integral_t Buxbaum(statbib) irbit1 random bit sequence recipes irbit2 random bit sequence recipes ISAAC Pseudo-random number generator that produces 32-bit  values. ISAAC has a minimal guaranteed cycle of 2^40 and an  average cycle of 2^8295. The results are uniformly distributed,   unbiased, and unpredictable unless you know the seed. The  internal state of ISAAC and the size of the seed are 8192 bits  wide. ISAAC is suited for cryptographic purposes.  http://delphi.icm.edu.pl/ftp/d30free/isaac.zip KolmogorovSmirnov Integral Buxbaum(statbib) LinearPeriodischeRang Corelation Buxbaum(circularbib) LiteraturVergleich Buxbaum(statbib) MRNG Fast BASM implementation of the "Mother-of-all Pseudo Random Number Generators" as proposed by well-known random number guru, Dr. George Marsaglia of the Department of Statistics, Florida State University. Freeware with source code. www.mindspring.com/~efd/tools.htm MRG32k3a MRG32k5a MRG63k3a. Comments from Andre Ratel about algorithms used in these routines.  Also see notes about publications by Pierre L'Ecuyer. ParametricRSqr Buxbaum(circularbib) pBeta (pBetaInv) Left tail probability in the beta distribution (and inverse) StatUnit(distr) pBin binomial right tail probability StatUnit(distr) pChi2 (pChi2Inv) Right tail probability in the chi square distribution with f degrees of freedom (and inverse) StatUnit(distr) PeriodischeRangCorelation Buxbaum(circularbib) PermutationX Permutation of r objects from n ESBMaths pFdistr (pFdistrInv) Right tail proability in the F distribution iwth (f1,f2) degrees of freedom (1-p percentile of F distribution) StatUnit(distr) pGamma (pGammaInv) Right tail probability in the gamma distribution (and inverse) StatUnit(distr) PKhi2 Probability of Pearson's Khi-2 TPmath1(fmath) PNorm pNormal (pNormalInv) Right tail probability in the normal distribution (and inverse) TPmath1(fmath) StatUnit(distr) poidev Poisson distributed random deviates recipes PoissCL lower 1-p confidence limits for lambda in Poisson distribution when n is observed StatUnit(distr) pPoiss Right tail probaility in the Poisson distribution StatUnit(distr) PSnedecor Probability of Snedecor's F TPmath1(fmath) PStudent Probability of Student's t TPmath1(fmath) pTdistr (pTdistrInv) Right tail probability in the T distribution (1-p percentile of T distribution) StatUnit(distr) ran0 random deviate by Park and Miller minimal standard recipes ran1 random deviate, minimal standard plus shuffle recipes ran2 random deviate by L'Ecuyer long period plus shuffle recipes ran3 random deviate by Knuth subtractive method recipes ran4 random deviate by DES-like hashing recipes RandG Function RandG(Mean, StdDev: Extended): Extended; generates data with given mean and standard deviation math, mathe Random Function Random [( Range: Integer)]; Returns a random number within the rnage 0 <= X < Range. If Range is not specified, the result is a real-type number within the range 0 <= X < 1. See Randomize. Random involves "compiler magic" since it is not treated like a real function.  The compiler creates code to call _RandInt or _RandExt, which can be found in the System.PAS unit.  See efg's UseNet Post about this. See Ray Lischner's UseNet Post clarifying parameter. system (uses "compiler magic") Random 16- and 32-bit random number generators from Communications of the ACM, June 1988, "Efficient and Portable Combined Random Number Generators," pp. 742-749, 774.  [See other Pierre L'Ecuyer's publications] Random16.TXT Random32.TXT Comments from Andre Ratel about algorithms used in the routines above and his routines MRG32k3a, MRG32k5a, and MRG63k3a. RandomGaussian Stockton Randomize Procedure Randomize; Randomize initializes the built-in random number generator with a random value obtained from the system clock. To initialize the random number generator to a repeatable value, assign a value to the RandSeed: LongInt variable. The RandSeed set by Randomize is related to the system clock.  See Randomize in the System.PAS unit for details. system Random Number Generators TPMath1(Random), TPMath2(RanTest) RanMul Random vector from a multinormal distribution TPMath2(RanMul) Rao Rao's Abstands-Test Buxbaum(circularbib) SekundaerAnalyse Buxbaum(circularbib) Stirling Stirling factorial approximation Turbo (p. 142) Wilcoxon Buxbaum(circularbib) ZeichneGruppierteDaten Buxbaum(circularbib) ZeichneMultiModal Buxbaum(circularbib) ZeichneUniModal Buxbaum(circularbib) ZufallAusBereich Buxbaum(zufallbib) ZufallBinomial Buxbaum(zufallbib) ZufallChiSqr Buxbaum(zufallbib) ZufallExponential Buxbaum(zufallbib) ZufallF Buxbaum(zufallbib) ZufallGamma Buxbaum(zufallbib) ZufallGeometrisch Buxbaum(zufallbib) ZufallPoisson Buxbaum(zufallbib) ZufallsZahl Buxbaum(zufallbib) ZufallT Buxbaum(zufallbib)

Curve Fitting, Regression, Least Squares, Data Modeling

Numerical Methods in Pascal page
http://www-rab.larc.nasa.gov/nmp/nmpIndex.htm#Optimization

The Shape of Data:   Object Pascal Implementations of Linear Least Squares
www.delphiinformant.com/features/1998/09/di199809rs_f/di199809rs_f.asp  (subscription)

 Function/Unit Name Description Source(s) ANOVA: FitANOVA, Estimate, DeleteOrthDesign, ConstructMinimum Analysis of variance models in orthogonal designs StatUnit(anova) Curve Fit A Delphi 4 (and 5) version of Allen Miller's Curve Fitting routine (from: the book "Pascal Programs For Scientists And Engineers", typed and submitted to MTPUG in Oct. 1982 by Juergen Loewner, and corrected and adapted for Turbo Pascal by Jeff Weiss.  Modified by David J. Taylor to work with Delphi 4's open array parameters, which allows the routine to be generalized so that it is no longer hard-coded to make a specific order of best fit or work with a specific number of points. http://www.david-taylor.pwp.blueyonder.co.uk/ software/CurveFit.zip fgauss fit a sum of Gaussians using mrqmin function recipes fit least-squares fit data to a straight line recipes FitConditionalLogitLinear, FitConditionalRasch Conditional logistic regression StatUnit(clogit) FitCoxModel Estimation in a multiplicative hazards survival model by maximization of Cox's likelihood StatUnit(newcox) FitExpo Fits a sum of decreasing exponentials, y = Ymin + A1.exp(-a1.x) + A2.exp(-a2.x) + A3.exp(-a3.x) + ... TP-Reg FitFrac fits a rational fraction : y = (p0 + p1.x + p2.x^2 + ..) / (1 + q1.x + q2.x^2 + ... ) TP-Reg FitHill fits the Hill equation : y = (Ymax . x^n) / (K^n + x^n ) TP-Reg FitIExpo fits the increasing exponential : y = A.[1 - exp(-k.x)] TP-Reg FitLin fits a linear function : y = a + b.x TP-Reg FitLogis fits the logistic function : y = A + (B - A) / [1 + exp(-a.x + b)] TP-Reg FitMich fits the Michaelis equation : y = Ymax . x / (Km + x) TP-Reg FitPKA fits the acid/base titration function : y = A + (B - A) / [1 + 10^(pKa - x) ] TP-Reg FitPoly fits a polynomial : y = b0 + b1.x + b2.x^2 + ... TP-Reg FitPower fits a power function : y = A.x^n TP-Reg FitMcCullagh, FitMcCullaghLogit, FitMcCullaghProbit, FitMcCullaghCLogLog McCullagh's model for grouped continuous data with unknown cutpoints StatUnit(mcunit) FitNegBin, SaveFittedNegBin Negative binomial distribution StatUnit(negbin) FitNonLinear, FitNonLinear1, InitNonLin, NLTestModelChange Nonlinear regression model StatUnit(nonlin) FitPosScale Estimate a general linear model with error distribution of any type StatUnit(posscale) fleg fit a Legendre polynomial using lfit or svdfit recipes fpoly fit a polynomial using lfit or svdfit functions recipes Least Squares Generalized Least Squares TP-GLS Least Squares Least squares fit to N sets of (x,y) points mathe lfit general linear least-squares fit by normal equations recipes Linear and Polynomial Regressions TPmath2(FitPoly) medfit fit data to straight line robustly, least absolute deviation recipes Models and Test. Models: Linear, Polynomial, Rational fraction, Sum of exponentials, Increasing exponential, Power, Michaelis, Hill, Logistic, Acid/Base titration curve. (See separate "Fit..." units in this section.) The Test program evaluates the regression routines in Models.PAS with the reference data sets provided by the National Institute of Standards and Technology (NIST). These data are available on the Internet at: http://www.nist.gov/itl/div898/strd/ general/dataarchive.html TP-Reg mrqmin nonlinear least-squares fit, Marquardt's method recipes Multiple Linear Regression TPmath2(FitMult) NonLinear Regression Sum of exponentials TPmath2(FitExpo) NonLinear Regression Rational Fraction TPmath2(FitFrac) Polynomial fit www.ibrtses.com/delphi/polyfit.html RegAn (Regression Analysis) RegAn.ZIP from Tim Gathercole Regression routines TPmath1(regress) rofunc fit data robustly, use by medfit recipes SlopeIntercept MathX svdfit linear least-squares fit by singular value decomposition recipes svdvar variances from sincular value decomposition recipes TLinApprox2D www.ibrtses.com/delphi/dlina.html

Sources Key

 Source Description/Location Buxbaum Dr. E. Buxbaum's statistics routines (comments in German): Buxbaum.ZIP ESBMaths ESBMaths is a collection of Integer and Floating Point Routines for Delphi™ 3 and 4- though it should work well in Delphi™ 2. Delphi™ Math unit not required. Includes probability and statistical related routines. New Unit (ESBMaths2) for Delphi 4 Dynamic Arrays, i.e. Vector Operations.  Includes Help File & Full Source. Freeware. ESB Consultancy: Developers of Mathematical & Statistical Software www.esbconsult.com.au ESB PDF Analysis Discrete & Continuous Probability Distributions.  Tool to aid in using Probability Distributions, both Discrete and Continuous. ESBPDF also includes many Reports and other useful tools.  Features include Binomial,  Poisson,   Normal, Exponential, Student t, Chi Squared and F Distributions; Inverses of Normal, Student t, Chi Squared and F Distributions; Lists of Binomial Coefficients, Factorials and Permutations; Fully Customizable; Integrated Help System which includes a Tutorial. We also plan on adding many more Distributions and features. www.esbconsult.com.au/esbpdf.html ESB Stats Statistical Analysis & Inference Package covering everything from Average, Mode, Variance through to Hypothesis Analysis, Time Series & Linear Regression. Including Online Help, Tutorials, Graphs, Summaries, Import/Export, Customisable MS Office 97 Interface, Calculator, Word 97 like Spell Checking and more. For Win32 Platforms. Install/Uninstall www.esbconsult.com.au/esbstats.html math Borland's Delphi math unit mathe Scientific Subroutine Library MathX www.razorsedgesoft.com/mathx.htm recipes Numerical Recipes Pascal shareware version ftp://garbo.uwasa.fi/pc/turbopas/nrpas13.zip RxLib www.rxlib.com  (file: MaxMin.PAS) StatUnit www.math.ku.dk/ims/software/index.html STATIS Most fundamental  procedures of mathematical statistics. Along with the Gamma  and the Beta function, all major types of distributions are  implemented   (normal, t, F, and chi-square distribution). http://www.lohninger.com/statis.html Stockton Dr. John Stockton's Pascal Maths Page http://www.merlyn.demon.co.uk/pas-math.htm SysUtils Borland's Delphi SysUtils unit TPmath1 TPmath2 TP-GLS TP-Reg Jean DeBord's TPMath www.unilim.fr/pages_perso/jean.debord/tpmath/tpmath.htm Turbo Turbo Algorithms (C, Pascal, Basic, Prolog) Keith Weiskamp, Namir Shamas, Ron Pronk John Wiley, 1989 (Out of Print)

 Airport Simulator Simulate an airport landing and takeoff pattern. The airport has 3 runways, two primarily for landing and one mainly for takeoffs. There are two arrival holding pattern queues for each of runways 1 & 2 and three departure queues, one for each runway. The queues are to be kept as close to the same size as possible. www.delphiforfun.org/Programs/airportsim.htm baseSim baseSim Simulation Components form an Object-Oriented Suite of   Borland Delphi Components which can be used to build Simulation Models and Simulation Applications. baseSim features:  Easy to  use and to develop Rapid 'Drag and Drop' development Ability to   build complex, flexible and standalone Models High speed, fully   compiled execution Close integration to Delphi. www.solutionsbase.co.uk/products/products.htm Cluster Ben Ziegler demonstrates graphically a simple and easy clustering algorithm. Great example.  www.radix.net/~bziegler/Delphi/cluster.zip Curve Fitting www.geocities.com/SiliconValley/Bay/9187/curvfit.zip Delsi Discrete-event simulation system implemented as a set of components for Delphi 3.  The system is intended for simulation of queuing systems with a complicated logic.  In combination with Delphi, Delsi gives you very flexible and powerful framework for creation of a wide variety of simulation models, implemented as end products for MS Windows95/NT. www.softland.rv.ua/delsi.htm Dew Research Probabilites package (freeware!).  The package includes a replacement for Delphi's Math unit and a set of 19 different probabilities functions. Binaries are freeware and the source is for sale. The package also compiles under Kylix and is for now the only part of MtxVec that also runs under Linux and Visual Basic Statistics package (MtxVec Add-On).  Statistics v1 is a MtxVec Add-On library with many statistical and mathematical routines. It comes with 16 different distributions random generators, Hypothesis testing, Analysis of variance, Principal component analysis, Linear and multiple linear regression, Non-linear regression, Statistical charts, Easy-to-use set of components, and more... This package offers statistical routines for Delphi v4,5,6 and  C++Builder v4,5 developers. Among others it containes: 19 different distributions (PDF, CDF and inverse CDF function),  mean and variance for all 19 distributions, random generators  for 15 distributions, parameter estimate for beta, binomial,   exponential, gamma, geometric, normal, Poisson, continuous uniform and Weibull distribution. Descriptive statistics:  histograms, ogives nth-Moment, percentile, range, Interquertile   Range IQR, mean, harmonic mean, geometric mean, trimmed mean,   median, skewness, kurtosis, standard deviation, root mean square   RMS, minimum, maximum, covariance, correlation matrix,   cumulative sum Principal component analysis (PCA): PCA by using   the covariance matrix, PCA Residuals, Barlett test for dimensionality, Hypothesys testing: Nonparametric tests (sign test, Wilcoxon tests) Parametric tests (one-sample t-test, two-sample paired/unpaired t-test), Z test, Regression models:   linear (weighted, unweighted), multiple linear (weighted,  unweighted), ridge regression, non-linear regression (using the BFGS, Marquardt or Simplex method) , one-way and two-way ANOVA.   http://delphi.icm.edu.pl/ftp/d40share/Statist1.zip See the Delphi Studio Companion Tools CD #1 for Statistics V1 for Delphi 7 Trial Gauss Example of Graph of Distribution of Frequencies and Deviation    Standard / Bell of Gauss in function of the obtained measures   and the values of control of a normal productive process.  Uuses the basic components of Delphi, with the  graphics of TeeChart.  http://delphi.icm.edu.pl/ftp/d40free/gauss6en.zip Gambling trip Simulator Simulate different betting styles for your next Vegas trip www.radix.net/~bziegler/Delphi/tripsim.zip Linear regression LRegress class from Engineering Objects International www.engineeringobjects.com/LinearRegression.htm MATH2 Offers some of the most fundamental procedures of univariate statistics (such as mean values, standard deviations, or the correlation coefficient for a series of data pairs). www.lohninger.com/math2.html Multiple Regression, Statistical Analysis Components www.xs4all.nl/~dgb/delmath.html#C_COMPONENTS Random Number Generationtion ``Random Number Generation'', Chapter 4 of the Handbook on Simulation, Jerry Banks Ed., Wiley, 1998, 93--137. (Introductory tutorial on RNGs). This handbook won the best book award for an engineering-related handbook for 1998, by the Association of American Publishers.    By Pierre L'Ecuyer. Random number generator for various distributions by W.Gross ftp://garbo.uwasa.fi/pc/turbopa7/rndgen10.zip Random Numbers and Monte Carlo Methods http://random.mat.sbg.ac.at/links Random Thoughts -- A Look at Generating Random Numbers with Delphi by Keith Wood in the March 1997 Delphi Informant. Round and Round Julian Bucknall goes round and round and round... and asks how random your numbers really are. Random number generators pop up surprisingly often and the numbers they generate can be surprisingly un-random!  Delphi Magazine, Issue 33, May 1998. Shape of Data Object Pascal Implementation of Linear Least Squares, Delphi Informant, Sept. 98, pp. 54-58. www.informant.com/libs/delphi/3x/di9809rs.zip Statis Fundamental procedures of mathematical statistics. Along with the Gamma and the Beta function, all major types of distributions are implemented (normal, t, F, and chi-square distribution).  www.lohninger.com/statis.html Statistics Engineering Objects International Statistics classes to augment Delphi math unit www.engineeringobjects.com/Statistics.htm Statistics by Fred Edberg Simple bivariate linear regression; clustering algorithms; Multivariate linear regression; ANOVA  www.ipns.com/fedberg Statistics Package www.dewresearch.com/products/Statistics_index.htm Ultimate Random Number Suite Engineering Objects International Incorporates six random number generators for Delphi 4, 3, 2, 1, & C++Builder. Eight classes programmed by Peter N Roth and Stefan Hoffmeister form a simple hierarchy for generating random numbers. 