46838-S99 Machine Learning for Computational Finance MATLAB Tutorial
Introduction
The primary purpose of this tutorial is to give you a little experience in using MATLAB, which you will need for upcoming assignments. A secondary benefit is practice on combinatorics; methods of counting. This will help with analyzing numbers of possible instances, size of concept space and hypothesis space, complexity of machine learning algorithms, etc.
Actions you should take will be numbered
and printed in italics.
Getting Started
-
1. Start MATLAB
- New York: The MATLAB executable can be found under the T
drive 'applications GSIA FASTlab'. Open the MATLAB\bin\ directory
and find the 'matlab' executable
- London: you will be receiving a CD with matlab; install
this where you will.
-
2. Copy the files you will need to your local machine
- The files you will need for the tutorial can be found
here
-
3. Add the folder containing these files to your MATLAB path
Go to Set Path under the File Menu. You may get an error massage initially;
ignore this and kill the error window. You will see a list of matlab
files already in your Path. On the right hand side at the top, you will
see a button Add To Path. Follow this and add in the directory you saved
the files in.
MATLAB Variables
-
4. Consider a problem in which you have to plan a holiday. There are 8 different day-long activities you could take part in, and you have three vacation days to spend.
Assign the variable activities with the value 8:
>> activities = 8
- 5. Inspect the value of the variable activities
>> activities
-
6. Assign the variable vacation_days with the value 3
Matlab Functions
.m files are functions. So long as they are in the path, they are
invoked as follows:
>> [output] = fx(parameter);
parameter may be a list of parameters, and output may be a list of
variables. Once the command is invoked, the variables are in memory
and can be further manipulated.
Typing
>> output
Will simply list the content of the variable 'output'.
How to use the .m files
factorial.m
- 7. factorial.m is used as follows. At the matlab prompt, type
>> [eight_factorial] = factorial(8)
the variable in [] will contain the results of the factorial calculation; the
variable in () is the parameter you give it.
recall that "n factorial" is commonly written "n!" and that
n! = n * (n-1) * (n-2) * ... * 1
0! = 1
- 8. n! is the number of ways of arranging n different objects. Suppose you wanted to find the number of ways all activities could be ordered. Find the value of factorial(activities)
n_choose_k.m
General
- 12. You are attempting to learn the concept UnhappyCustomer. You have 12 different variables you will take into account. Each of the variables has two different values.
- What is the size of the instance space?
instance_space = 2^12
- Your concept can be Yes or No; what is the size of the concept space?
- Now you allow your concepts to answer the question as "Yes", "No", and "Maybe";now what is the size of your concept space?
- Your hypotheses consist of conjunctions of two variables; what is the size of your hypothesis space?
Rosie Jones
Last modified: Sat Mar 27 12:06:28 EST 1999