Getting started with GAUSS

Goals

After this tutorial, you should be able to

  1. Run interactive commands in GAUSS.
  2. Create matrices and vectors.
  3. Create strings.
  4. View workspace variables.
  5. Print numeric and string output.
  6. Index matrices.
  7. Call functions.
  8. Configure the GAUSS user interface.
  9. Run example programs.
  10. Get help on a function.

Interactive commands

Open GAUSS and click on the Command tab on the left side of the GAUSS user interface. This will take you to the Command Mode, which contains:

  • The Command History window, which keeps track of your recent GAUSS commands.
  • The Program Input/Output window where you can enter interactive commands and see the output from interactive commands and programs.

Enter interactive commands in GAUSS.

Let's start with a simple calculation of the Body Mass Index (BMI). The formula for BMI is

$$BMI = weight / height^2$$

For a person who weighs 81.6 kg and is 1.75 m tall, we would enter the command as shown in the image above.

Matrix and vector creation

Most of the time in GAUSS, you will be working with matrices and vectors. Matrices and vectors are created by placing a list of numbers inside of curly braces {} with commas separating the rows.

// Create two, 3x1 vectors
weight = { 81.6, 72.5, 78.2 };
height = { 1.75, 1.82, 1.55 };

Then we use the dot operators to perform element-by-element operations on the vectors.

// Use 'dot' operators to perform element-by-element operations
bmi = weight ./ height .^ 2;

After the code above, bmi equals

26.644898
21.887453
32.549428

String creation

Strings are GAUSS variables that contain characters. String data is declared inside of double-quotes, ".

// Create a string
my_string = "This is my first string!";

Workspace variables

All data created in GAUSS are considered Workspace Variables. You can view the data in your GAUSS workspace by clicking on the Data tab on the left side of the GAUSS interface.

View data in GAUSS.

Double‐click the name of a variable, to view its entire contents.

Clearing the workspace

The new command will remove all variables from your GAUSS workspace.

// Remove all workspace variables
new;

  • The print keyword in GAUSS takes a space‐separated list of items to print.
  • Expressions should be surrounded by parentheses.
mass = 12;
acceleration = 2.5;

force = mass * acceleration;

// Print a string and a workspace variable
print "Force = " force;

// Print a string and an expression
print "Force = " (mass * acceleration);

Both of the above print statements will produce the output below.

Force = 30.0000

Implicit print statements.

The print keyword is not strictly required. For example:

mass = 4;

// Entering a workspace variable
// name alone is an implicit 'print'
mass;

will return the output:

4.00000

Clearing printed output

You can remove all printed output with the cls command. cls stands for 'clear screen'.

// Clear the program input/output window
cls;

Calling functions

GAUSS has more than 1000 built‐in functions.

  • Inputs to GAUSS functions or procedures are passed inside of parentheses.
  • Return values are always on the left side of the equals sign.
// Declare a 2x2 matrix
prices = { 100 50,
            90 25 };

// Compute the mean of each column
price_bar = meanc(prices);

// Compute the max of each column
price_max = maxc(prices);

will make the following assignments:

price_bar =   95
            37.5

price_max = 100
             50

Indexing

GAUSS uses square brackets [] for indexing. For example:

// Declare a 3x2 matrix
A = { 21 33,
      14 19,
      25 18 };

// Assign 'B' to equal the element
// from the 2nd row of the first
// column of 'A'
B = A[2,1];

will assign B equal to

14

The colon operator : indicates a range. For example:

// Assign 'B' to equal the first two elements
// from the 2nd column of 'A'
B = A[1:2,2];

will assign B equal to

33
19

Configure the GAUSS User Interface

We will now move to the GAUSS Edit Mode. The Edit Mode is where you will likely spend most of your time in GAUSS. It allows you to:

  • Open, edit and run GAUSS program files.
  • Keep track of different folders and libraries.

Click the Edit tab on the left side of the GAUSS user interface to go to the Edit Mode.

Customize widget locations

To relocate a GAUSS widget (or window):

  1. Grab the title bar of the widget with your mouse and drag it to your desired location.
  2. When the window is over a valid location, a drawer will open indicating the landing place for the widget.
  3. Let go of your mouse and the widget will be dropped into the new location as shown below.

Configure GAUSS interface.

Open widgets

All available widgets may be opened from the GAUSS View menu as shown below. Note that each GAUSS Mode (Command, Edit, Data, Debug, Graphics and Help) will have different widgets available.

Open widgets in the GAUSS user interface.

Run example programs

The example programs that come with GAUSS are located in GAUSSHOME/examples, where GAUSSHOME is your GAUSS installation directory. To make it easy to browse the example files, we will open our GAUSSHOME directory in the project folders window.

Open a project folder

The Project Folder window allows you to view the contents of any folder on your computer. You can open a particular folder by either:

  • Right-clicking in the Project Folder Window and selecting Add Folder.
  • Selecting File > Open Project Folder from the main GAUSS menu.

Open a project folder in GAUSS.

Next, an operating system file explorer will open. Browse to your GAUSS installation location and open the folder. Once this is accomplished, expand the GAUSS installation folder and examples folders nodes. You should now see the list of GAUSS example files and datasets as shown below.

Project folders in GAUSS.

All of the GAUSS example programs end with the file extension .e.

  1. Scroll down and locate the example glmbinomial1.e.
  2. Double‐click its name in the list to open the file.
  3. To run this example file:
    • Click the downward pointing arrow just to the right of the Run button on the GAUSS toolbar.
    • Select Current File as shown below.

Run the current file.

You should now see the output from the generalized linear model estimation printed in the GAUSS program input/output window as in the image above.

Get help on a function

You can get help on GAUSS functions by highlighting the name of the function with your mouse, right‐clicking and selecting Help on Selected Text from the context menu.

Get help on functions in GAUSS.

If you do this for the function, glm, as shown in the above image, you will find information about the inputs and outputs of the function as well as 10 different examples.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.