* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Gauss Commands Replace words in italics with file paths/names
Survey
Document related concepts
Tensor operator wikipedia , lookup
Cartesian tensor wikipedia , lookup
Quadratic form wikipedia , lookup
System of linear equations wikipedia , lookup
Rotation matrix wikipedia , lookup
Eigenvalues and eigenvectors wikipedia , lookup
Jordan normal form wikipedia , lookup
Determinant wikipedia , lookup
Four-vector wikipedia , lookup
Matrix (mathematics) wikipedia , lookup
Singular-value decomposition wikipedia , lookup
Perron–Frobenius theorem wikipedia , lookup
Non-negative matrix factorization wikipedia , lookup
Cayley–Hamilton theorem wikipedia , lookup
Transcript
Gauss Commands Replace words in italics with file paths/names, variables, or values. The character | separates lists of options. Command @ ; output file = “filename” on | off | reset Explanation Precedes and follows a comment. Gauss will ignore everything between two @ symbols. Each line in a Gauss program must end with a ; character. The character is not required when entering commands directly. Opens an output file. The ON option creates the file if it doesn’t exist and appends output to the file if the file already exists. The OFF option closes the file. If you do not issue the OFF command, you may lose output that is stored in the output buffer but not yet written to the file. The RESET option creates the file if it doesn’t exist and overwrites the file if the file already exists. After turning on (or resetting) an output file, all “print” commands send data to both the screen and the printer. Example @ This is a comment. @ load x[3,4] = “a:/data.txt”; y=x’x; print y; output file = “a:/data/results.txt” reset Note: Gauss uses linux notation for directory paths. Use forward slash instead of back slash. print “x” Prints the character “x” print object Prints to the screen or a file. print x Prints the value of the variable x. load x[3,4] = “a:/data.txt” load matrix[r,c] = “filename” save matrix xlsreadm(“filename”, “range”, sheet) Reads data from a text file into a matrix that is r rows by c columns. Saves matrix to the filename matrix.fmt Reads data from an Excel file into a matrix. Range is the range of cells containing the data. Sheet is the number of the sheet within the workbook. Note: Gauss uses linux notation for directory paths. Use forward slash instead of back slash. save x x = xlsreadm(“a:/data.xlsx”,“a1:d20”,1) x = {1 5 7, 9 4 2, 4 4 8, 4 2 4} matrix = {x11 x12, x21 x22, x31 x32} Creates a matrix of numbers. Spaces separate columns. Commas separate rows. 1 9 creates the matrix 4 4 matrix’ Transposes a matrix. If x = 1 2 3 4 5 6 5 7 4 2 4 8 2 4 1 4 then y’ = 2 5 3 6 x = ones(4,3) ones(r, c) Creates an r x c matrix of ones. 1 1 creates the matrix 1 1 1 1 1 1 1 1 1 1 x = zeros(4,3) zeros(r, c) Creates an r x c matrix of zeros. 0 0 creates the matrix 0 0 0 0 0 0 0 0 0 0 x = eye(3) eye(n) Creates an n x n identity matrix. inv(matrix) Inverts a matrix. The matrix must be square. 1 0 0 creates the matrix 0 1 0 0 0 1 1 2 If x = , then 3 4 1 2 inv(x) = 1.5 0.5 1 2 3 4 , then 1 diag(x) = 4 If x = diag(matrix) Extracts the diagonal from a square matrix. 0 0 0 0 and y = 5 0 diagrv(x,y) = 0 6 If x = diagrv(matrix, vector) meanc(matrix) stdc(matrix) show matrix new cls Inserts the elements in vector into the diagonal of matrix. Returns the means of the columns of matrix. Returns the standard deviations of the columns of matrix. Shows the dimensions of matrix. Clears variables from memory. Clears the output screen. Multiplies two matrices. The number of columns in the first matrix must equal the number of rows in the second matrix. * Note: When pre-multiplying by a transformed matrix, you can omit the * symbol. Example: x’y instead of x’*y + Adds two matrices. The numbers of rows in the two matrices must be the same and the number of columns in the two matrices must be the same. - Subtracts two matrices. The numbers of rows in the two matrices must be the same and the number of columns in the two matrices must be the same. Kronecker multiplies matrices. two .*. .* Hadamard multiplies ʘ two matrices. Hadamard multiplication is element-byelement multiplication. 5 6 then show x new cls 1 2 3 If x = and y = 4 5 6 then x*y = 22 28 49 64 1 3 6 x+y = 10 1 If x = 3 4 x-y = 4 1 If x = 3 1 3 x.*.y = 0 0 1 If x = 3 1 x.*y = 0 2 5 and y = 7 4 8 12 2 5 and y = 4 7 4 4 2 1 and y = 4 0 2 0 0 4 0 0 0 2 4 0 6 8 2 1 and y = 4 0 0 8 If x = 1 2 3 4 , 5 6 6 , then 8 6 , then 8 0 , then 2 0 , then 2 1 2 5 6 3 4 and y = 7 8 , then 0.20 0.33 x./y = 0.43 0.50 1 3 If x = and y = , then 2 4 1 3 x~y = 2 4 1 3 If x = and y = , then 2 4 1 2 x|y = 3 4 1 2 3 If x = 4 5 6 , then 7 8 9 If x = ./ Element-by-element division. ~ Column-wise concatenation. | Row-wise concatenation. matrix[r1:r2, c1:c2] Extracts a portion of a matrix. x[1:2,3:3] = 3 6 Note: A single period, “.”, means “all rows” or “all columns”. rows(matrix) cols(matrix) cdftc(test statistic, degrees of freedom) cdftci(area to the right, degrees of freedom) cdfchic(test statistic, degrees of freedom) Returns the number of rows in matrix. Returns the number of columns in matrix. Returns the area to the right of the test statistic for a tdistribution with the indicated degrees of freedom. Returns the t-score that yields the indicated area on the right side of a t-distribution with the indicated degrees of freedom. Returns the area to the right of the test statistic for a χ2 If x = 1 2 3 4 5 6 , then rows(x) = 2 If x = 1 2 3 4 5 6 , then cols(x) = 3 cdftc(1.6,10) returns the value 0.0703 cdftci(0.025,100) returns the value 1.9840 cdfchic(2,3) returns the value 0.5724 cdffc(test statistic, degrees of freedom numerator, degrees of freedom denominator) distribution with the indicated degrees of freedom. Returns the area to the right of the test statistic for an F distribution with the indicated degrees of freedom. 1 4 1 abs(x) = 4 If x = abs(matrix) Converts each element of matrix to its absolute value. 3 , then 5 6 2 3 5 6 2 edit c:/users/default/desktop/prg.txt edit filename do until condition; [program code] endo; Create a text file for executing Gauss code. Repeatedly executes a block of code until condition is met. The condition is tested when the program encounters the endo command. Note: Gauss uses linux notation for directory paths. Use forward slash instead of back slash. j = 1; do until j == 10; print j; j=j+1; endo; Note: When evaluating a variable, use double equal signs. When setting the value for a variable, use a single equal sign. for j (1, 10, 1); print j; endfor; for variable (start, stop, step); [program code] endfor; Repeatedly executes a block of code with variable starting at the value start, incrementing by step, and continuing until it reaches the value stop. if condition; [program code] endif; Executes a block of code provided that condition is met. The condition is tested when the program encounters the endif command. if j < 10; j=abs(j); endif; label: Marks a place in a program to which control can be sent. goto RunRegression; [program code] RunRegression: [program code] goto label Sends control to another point in a program. goto RunRegression gosub label return Sends control to another point in a program. Control returns where it left when the program encounters “return”. gosub RunRegression; [program code] RunRegression: [program code] return; lagn(matrix, index) Lags matrix by index time periods. xlagged = lagn(x,1) Note: When evaluating a variable, use double equal signs. When setting the value for a variable, use a single equal sign. packr(matrix) rndn(rows ,columns) Deletes the rows of a matrix that contain any missing values. Generates a rows by columns matrix of standard normally distributed random numbers. x = packr(x) x = rndn(100,1)