Monthly Archives: November 2016

Building blocks of genetic algorithm in TI Nspire

Genetic algorithm is one of the more popular evolutionary algorithm with wide range of usage including optimization. While there are a lot of implementation of this technique, including the one as an option in the Excel solver, building one is a very good choice to understand the underlying process.

The TI Nspire provided a rich set of matrix operations that can be utilized to model the data structure required genetic algorithm. For example, creating an initial population with arbitrary size of binary, integer, or real numbers.

ga1

The cross over operation can be modeled as extracting part of a matrix using the augment function.

ga2

Fitness function can be dynamically defined using the expr function available in the Nspire environment.ga3

 

Exploring Lorenz system in TI Nspire

The Lorenz system is a non-linear system involving three parameters. It is three dimensional and can be plotted for visualization. Although the Nspire is capable to plot 3D graphs, sequence functions is supported in 2D plot only. Even so, it is still good to explore this chaotic system.

The three axis x,y,z are represented using the sequence functions u1, u2, and u3 respectively.lorenz1
Clicking CTRL-T will open the Data page alongside the plot.
lorenz3

Resulting pattern in scatter plot resembles the famous 3D plot even if it is 2D.
lorenz2

GARCH model in R

A much more practical approach than calculating GARCH parameters on a calculator is to do it in R. Not only is there is available packages, retrieving financial data for experimenting is also a piece of cake as the facilities built-in offered convenient access to historical data.

To use GARCH in R the library must be installed first.

fgarch1

To test the library, data are imported using the tSeries package.

fgarch2

 

A plot of the log return.

fgarch3a

fgarch3

 

Before running the GARCH model, a QQ plot is reviewed.

fgarch4a
fgarch4

 

Finally, the GARCH model is created using the command below.

fgarch6

 

Density plot.

fgarch5a

fgarch5

 

With trace=off a clean model can be printed after running the model.

fgarch7