## Psych 285: Computational Statistics

and Statistical Visualization## Professor Forrest Young

## Assignment 1

Functional Programming - 1

Due Monday, January 29

Write CENTER, a function that column-centers a matrix X (i.e., makes the mean of each column zero). The function should take a matrix as its only argument and should return the centered matrix. Do this in the following two ways:

- Use the matrix functions ARRAY-DIMENSIONS, MAKE-ARRAY, TRANSPOSE, and MATMULT to implement the formula X-(1'*1*X)/n, where n is the number of observations.
- Use the Lisp functions APPLY, BIND-COLUMNS, MAPCAR, LAMBDA, MEAN and COLUMN-LIST to subtract the mean of each column from the column.
Please send your code to me by e-mail before class on the due date.

## To get in touch:

email: forrest@unc.edu WWW: http://forrest.psych.unc.edu