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)