Quantitative Finance II Introduction to Mathematica: Simulation of Various Time Series Summer Semester 2009/2010 by Jozef Baruník * If viewed in .pdf format - for full functionality use Mathematica 7 notebook (.nb) version of this .pdf This material serves as an general introduction to Mathematica environment including methods for Time Series simulation, Exporting and Importing the simulates Series, Plots, etc. as well as work with Financial Data. Introduction to Mathematica Use Mathematica just like a calculator: you type in a question and Mathematica gives you the answer Always use "Shift + Enter" to evaluate the input: 2 + 2 2 Type "2" "spacebar" and "2" to multiply: 2 μ 2 4 2D quick plot of function Plot@Sin@1.5 xD ^2, 8x, 0, 10<D 2 4 6 8 10 0.2 0.4 0.6 0.8 1.0 What is wrong? 2D quick plot does not work. Always use capital letters of functions, if anything goes "blue", it means that the funciton is unde- fined and Mathematica do not know what to do. To correct this line, just use capital P in "Plot": plot@Sin@1.5 xD ^2, 8x, 0, 10<D plotASin@1.5 xD 2 , 8x, 0, 10<E Go interactive and explore the behavior of function SinHaxL 2 when changing parameter a:
8
Embed
Quantitative Finance II - avcr.czstaff.utia.cas.cz/barunik/files/QFII/QF_Intro_to_Mathematica.pdf · Quantitative Finance II Introduction to Mathematica: Simulation of Various Time
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Quantitative Finance II
Introduction to Mathematica: Simulation of Various Time Series
Summer Semester 2009/2010 by Jozef Baruník
* If viewed in .pdf format - for full functionality use Mathematica 7 notebook (.nb) version of this .pdf
This material serves as an general introduction to Mathematica environment including methods forTime Series simulation, Exporting and Importing the simulates Series, Plots, etc. as well as workwith Financial Data.
Introduction to Mathematica
Use Mathematica just like a calculator: you type in a question and Mathematica gives you theanswer Always use "Shift + Enter" to evaluate the input:
What is wrong? 2D quick plot does not work.Always use capital letters of functions, if anything goes "blue", it means that the funciton is unde-fined and Mathematica do not know what to do. To correct this line, just use capital P in "Plot":
ListPlot@Table@i^2, 8i, 0, 10, 2<D, Joined Ø TrueD
1 2 3 4 5 6
20
40
60
80
100
Do not know how to change the plot? Use HELP (click on ">>" to get full help of function)
? Plot
Plot@ f , 8x, xmin, xmax<D generates a plot of f as a function of x from xmin to xmax.Plot@8 f1, f2, …<, 8x, xmin, xmax<D plots several functions fi. à
No we have AR(1) saved in "ar1" variable so we can plot it:
ListPlot@ar2, Joined Ø True, Frame Ø True, PlotStyle Ø BlackD
0 100 200 300 400 500
-2
0
2
4
Simulate ARCH(1) process:
at = st et,
st2 = a0 +a1 at-1
2 ,
where a0 > 0, a1 ¥ 0.
Again set parameters first:
In[1]:= paramp0 = 0.1;paramp1 = 0.3;
Now we have to use the trick and create list so Mathematica will be able to iterativelly write into thislists We need 2 processes, so we have to have 2 lists with initial conditions (note that in the previ-ous examples, initial conditions where automatically generated)