|
OR/MS Today - October 2003 Software Review GAUSS Mathematical and Statistical System 5.0 Workhorse programming language proves a valuable tool for financial, econometric and statistical professionals and students, as well as operations researchers By ManMohan S. Sodhi and Wayne Holland The world of Aptech Systems' GAUSS Mathematical and Statistical System (GAUSS) 5.0 is a veritable universe with generations of econometrics and finance researchers having grown up on it. But it is also a tool that is of value to operations researchers for designing their own algorithms, for doing quick simulations, or for teaching operations research and statistics. Our viewpoint for this review is that of a user who needs to use matrices or statistics a lot but does not have the time or expertise to program routines in lower-level languages like C, C++ or Java. GAUSS Features GAUSS is a both a high-level programming language for numerical, statistical and financial calculations, and a limited interactive environment. As a programming language, you can use GAUSS to write compact programs given the number of matrix-based statistical and financial functions already built into the language. Moreover, these programs can be compiled so that you do not actually have to run a program for several minutes only to find a typo in the last line. As an added plus, you can read and write data in the form of matrices into text files, into binary files and into Microsoft Excel spreadsheets. You can run GAUSS programs in command line mode (as in DOS or Unix) or in a limited Windows graphical user interface that essentially dresses up the command line mode. GAUSS is a computer language for numerical computation, its attraction being its handling of matrices in the same way as scalars. This fact, along with the built-in functions for matrices, makes for shorter and much less error-prone programs than if you were to write the same program in a lower level language like C or C++. For example: defines the matrix x = ![]() You can then perform such operations as: to calculate the determinant of x and would perform an LU decomposition on x, with the lower and upper triangular matrices returned in L and U respectively. (Note that the blank spaces on both sides of "L" and "U" are required, creating problems for those used to more modern programming languages. In GAUSS, not having whitespaces or having too many generates strange errors.) These matrix operators not only make it easy for users to create even higher-level procedures and for vendors, including Aptech Systems, to provide many specialist functions. For example, there is a large set of functions specifically designed for finance: AmericanBSCall calculates the American Black and Scholes call; EuropeanBSPut calculates the European Black and Scholes put; AnnualTradingDays, GetNextTradingDay, GetNextWeekDay calculate the appropriate time period. These functions are not easy to program as one of us can attest so it is very handy to have these as functions. There are also other finance- or econometrics-related programs written in GAUSS in the public domain, as will be detailed later. Then there is non-linear optimization that is catered for with Qnewton, quadratic programming that uses Qprog, and solution of a system of non-linear equations that uses eqSolve. [sqpSolveMT solves the non-linear programming problem; that is, it minimizes a general function subject to general non-linear constraints on parameters.] The range of statistical and probability-distribution-related functions is impressive. These include corrx to calculate the correlation matrix, meanc to calculate the mean value of each column of the given matrix, ols to perform ordinary least squares regression and pdfn to calculate standard normal probability density function values. In the public domain, one can even find improved versions of some of these statistical procedures (e.g., Vinod 2000). GAUSS also provides many functions for scientific computation. These include differentiation and integration, linear algebra, eigenvalue, fourier transforms and random number generators (rndnb generates a negative binomial pseudo random number, rndLCbeta calculate a beta pseudo random number). [GAUSS also has a state-of-the-art generator called K-M (for Kiss-Monster) that has a period in excess of 102857.] Moreover, you can get libraries from other vendors extending the capabilities of the basic GAUSS software. One library from Econotron Software allows linking to Maplesoft's Maple software that allows symbolic computation. Operations research professionals can get add-in modules for linear programming, time series and maximum likelihood. Those working on the marketing interface may find a recently released application (sold separately from the basic GAUSS software) called Discrete Choice useful for handling discrete models like multinomial logit, conditional logit and nested logit. Those familiar with GAUSS 4.0 will find the following additions in the reviewed version GAUSS 5.0: genetic algorithm, census X12 smoothing, binary matrix input/output, string evaluation and enhanced spreadsheet handling. Finally, GAUSS can be used to create graphs and pictures of various types, as well as manipulate these with a graphics editor. Moreover, in the reviewed version 5.0 for Windows specifically, the graphics editor can copy drawing objects and draw text at any angle. Programming in GAUSS We wanted to write a simulation program regarding the bullwhip effect. Having not used GAUSS earlier, one of us quickly skimmed through the example program that Aptech recommends: "ols.e" for doing an ordinary least squares regression and then ran that program. Next we wrote a simple program as follows: saved this in a file, hello.txt, and ran it (without compiling) by typing on the command line within the interactive environment (Figure 1). ![]() Figure 1: Interface for GAUSS, Windows version (click on image to view larger version in seperate window). Next, we skimmed through the User Guide with more attention to the chapter on the programming language constructs. For the program we had in mind, we needed to create arrays (for orders and for inventory levels over time at different supply chain nodes), go through iterative loops (for different parameter settings and over time), create random numbers (for forecast error in each time period) and calculate variance. We also looked at the Language Reference Guide to figure out how to compute variance. We found that splitting help between the User Guide and a Language Reference to be quite confusing to beginners like us even though after some time it is clear that language constructs are to be found in the former and the functions in the latter. The "help" system is similarly split up, and our suggestion to Aptech would be to have an integrated system in the graphical user interface where everything could be found in one place, a good model being Wolfram's Mathematica software. We then set about translating a program written in another software (Mathematica) to study the bullwhip effect. We had arrays declared with length to be determined at runtime. In the GAUSS manuals, at first we did not find "dynamic allocation" of vector length, so we got past this problem by defining the array length at compile time, e.g., x[580]. Later, however, we did find a reference for the call matalloc (similar to that in C language) in the Language Reference to dynamically allocate memory for a matrix. As a programming language, GAUSS has the feel of Fortran given its case-independence and procedures like gosub, but it also has the powerful set of string manipulation functions taken straight out of the C language. The language could be modernized by strengthening compile level errors (requiring all variables to be declared, for instance) and by better handling of whitespace (spaces and newline). As already mentioned, the latter can cause errors that are puzzling for new users, e.g., x[t+k] is fine but x[t + k] is not because the latter includes spaces inside the square brackets. Lines that are too long can cause strange compile-time errors but lines that are broken up by newline characters also cause problems. Given that GAUSS is primarily a programming language, its lack of a good programming environment is quite noticeable. The program editor in the Windows versions has much more features than Notepad in terms of offering colors and highlighted keywords but does not help in anticipating the function calls you are trying to make. If you intend to use GAUSS frequently and you are already familiar with some other editor like Emacs or Epsilon, you may prefer to stick with that. Aptech needs to provide a better programming environment that helps users, for instance, by lining up your code automatically or in anticipating function calls you are trying to make and finding more about these. A good model is the programming environment provided by Borland, eg., with their Java compiler, JBuilderTM. Using Help and the Manuals GAUSS was originally a terminal application that is still available along with a Windows-based one that is still in early stages. The manuals also need to be expanded, integrated and made accessible centrally through the "help" feature. Take for instance, the entry on transposing matrices: "The vector of dimension indices must be a unique vector of integers, 1-N, where 1 corresponds to the first element of the vector of orders, x is N-dimensional array, nd Nx1 vector of dimension indices, the new order of dimensions, y is a N-dimensional array, transposed according to nd." Despite the examples, I found it really difficult to transpose a column vector to a row vector. Later, we found a simpler and intuitive way that GAUSS offers: A' for A-transpose. It would be good for a cross-reference to have been made to this in the entry for atranspose. As such, you may need to subscribe to Aptech's Premium Services to get support. Although there are a number of functions for both scalars and matrices level, there are few at the level of scalars alone, perhaps to avoid confusion. For example, we had to define min(a,b) as a procedure ourselves for scalars a and b. We reproduce a simplified version of the program we created for this review in Figure 2. Regarding output, you can print to text files (or to the screen) and also to MS Excel spreadsheets. For printing to screen or to a text file, the default number of characters for a line is 80, but you can print your output in a wider file. It took us some time to hunt for information and finally found it in one of the Guide pdf files. The second and better alternative is to save your results to a matrix and then write that matrix directly into an Excel spreadsheet. However, this means storing all results in memory specifically in a matrix form that may not be suitable for all types of results (but you can do line-by-line output with some string manipulation within your code). Still, this option is better than writing to text files because accuracy of the numbers is preserved when you write to a spreadsheet directly. /*------ FUNCTIONS ----------*/ proc min(a,b); if a < b; retp(a); else; retp (b); endif; endp; /*------ CONSTANTS ----------*/ #define HZN 280 #define MAXLr 15 #define MAXLm 15 #define NRESROWS 9 #define NRESCOLS 4 iniQty = 1000 ; retSafetyStock = 50; fcstErrSD = 50; /*--- Create, initialize vectors --*/ let demand[HZN] = iniQty; let fcst[HZN,HZN]= iniQty; let retOrder[HZN]= iniQty; let retInv[HZN]= retSafetyStock; let eps[HZN]= 0; let mfrShipment[HZN]= iniQty; let results[NRESROWS,NRESCOLS] = 0; /*----- START SIMULATION ---------------*/ print "Beginning simulation"; resRow = 1; demand[t] = fcst[t,t]; Figure 2: A simplified version of the program in GAUSS used for this review Installing GAUSS If you purchase GAUSS from Aptech directly, you obtain the software by downloading it from Aptech's Web site, installing it and then requesting Aptech for a license file via e-mail. Our experience was with the Windows version, specifically with Windows 2000. After some starting hiccups, we were able to install and run the software. (GAUSS is available for Linux and various flavors of Unix as well.) There are a number of files in the download directory including that with a Quick Guide in pdf format that should be downloaded first because this will tell you which files should be downloaded. Upon unzipping downloaded files, you can click on the "setup" file. An install program takes you through the steps, the last of which generates information about your computer. You must e-mail this information to license@aptech.com requesting for the contents of a license file. You can cut-and-paste the information that is e-mailed to you into a "gauss.lic" file in your computer's directory where GAUSS is installed. Our hiccup was that the machine in question was a laptop with a docking station that needs to be registered differently. Once the problem was identified, we had no problems starting GAUSS. Areas of Improvement We have already said that the help system the manuals, and the programming environment could use improvement, modernizing and updating. In addition, concerns have been raised regarding numerical stability of some of the statistical and the equation-solving procedures in comparison to other statistical packages and regarding randomness of the random number generator [Vinod 2000]. These concerns were raised for an earlier version (GAUSS version 3.27 for Windows) so some of the problems may have been fixed. In any case, tests for numerical accuracy can be repeated by running the GAUSS programs used by Vinod (2000) at the Web site www.fordham.edu/economics/vinod/jae.htm. The GAUSS Universe in the Internet As GAUSS has been a staple for econometrics and finance professionals for a long time, there are many resources on the Internet. There is a mailing list called Gaussians. To subscribe or unsubscribe from this list, send the command subscribe gaussians in the body of an email message (not on the subject line) to majordomo@eco.utexas.edu. To access archives, visit www.rhkoning.com. A major source of archived GAUSS software is maintained by Alan Isaac at the American University at www.american.edu/academic.depts/cas/econ/gaussres/GAUSSIDX.HTM. The site also provides links to other resources on the Web. Aptech also provides numerous links at its own Web site http://www.aptech.com/AS_resLibMF.html. Overall Summary GAUSS has been a workhorse for many financial, econometric and statistical professionals, researchers and students. For operations researchers, it is a good tool for matrix manipulations and for teaching classes on matrix algebra or algorithms. Our initial test runs, including learning GAUSS and translating the simulation program to GAUSS, took only a day. So most users with rudimentary programming skills will find GAUSS easy to pick up and do useful things with in a few hours. Even if you will eventually code in C, C++ or Java, the investment needed to code in GAUSS is low enough to justify its use to check intermediate and final results. Its bare bones approach appears to translate into speedy results from concepts to results for an expert user, but the same approach is a limitation for new users more used to mouse-and-click than to the so-called terminal applications.
References
ManMohan Sodhi and Wayne Holland are members of the operations management faculty at Cass Business School in London. OR/MS Today copyright © 2003 by the Institute for Operations Research and the Management Sciences. All rights reserved. Lionheart Publishing, Inc. 506 Roswell Rd., Suite 220, Marietta, GA 30060 USA Phone: 770-431-0867 | Fax: 770-432-6969 E-mail: lpi@lionhrtpub.com URL: http://www.lionhrtpub.com Web Site © Copyright 2003 by Lionheart Publishing, Inc. All rights reserved. |