Monthly Archives: February 2015

CUDA 6.5

It has been months since the official release of CUDA 6.5 and it is about time to upgrade from 5.0. The performance improvements in double precision is noticeable in the new release, and there is no change of code required. The toolkit download is around 1GB and the installation is flawless (except DOSBos crashed in the middle).

Using -fp64 switch, the nbody benchmark on CUDA 6.5 scored 8.23 GFLOPS whereas on CUDA 5.0 it is 7.79 GLOPS.cudanbody-double

No significant improvements on single precision (45.28 and 45.07 on CUDA 6.5 and CUDA 5 respectively).cudanbody-single

The n-body CUDA program for bench-marking. cudanbody-double-running

Looking forward to CUDA 7.0. As of writing it is in Release Candidate status.

Advertisements

Multiple linear regression by weighted least squares on the Nspire

When performing data analysis, it is sometimes desirable to assign weights to selected data according to their perceived values. For example, data that are more reliable are assigned a higher weight, or weight value that is inversely proportional to variance of that data value. This technique can be applied to multiple linear regression as well. In the more common regression method by ordinary least squares (OLS), all observed data are of the same weight. In weighted least squares (WLS), an arbitrary weight value is assigned to each of the observations. WLS is a special case of generalized least squares (GLS) method.

The regression analysis in Nspire supports only the OLS method. Programming is required to adopt the WLS. Fortunately, the built-in programming by the Nspire supports accessing data stored in the spreadsheet application in the form of  lists and matrices, which are heavily relied upon on the calculation of WLS statistics. Needless to say Nspire is good at performing matrix operations.

Similar to OLS, the WLS approach is based on the minimization of the sum of squares between sets of data, from which the parameters for the regression equation are obtained. In WLS, the equation is given by

β = (XT Λ-1 X)-1XTΛ-1Y

where  Λ is the covariance matrix used to determine the weights, and can be represented by the piece-wise equation

LRWLS1

The total sum of squares in WLS is given by

LRWLS2-SSTO

and the sum of squares error by

LRWLS3-SSE

For visualization, the response plane plot of the regression equations obtained from a sample data set by OLS with the Nspire built-in multiple linear regression and the WLS program respectively are generated using the 3D function plot.

LRWLS4-3DPLOT

Conversion of system mode settings from Nspire to TI-89

Mode settings can be done on both the Nspire and TI-89 using the setMode() call. After finding out the parameters and values differ significantly when porting TI-BASIC program from the Titanium to the Nspire, a chart showing the corresponding TI-89 values will be handy. The Titanium required string type for the arguments in the setMode() call.

setmode-comparison

Some mode setting options available in the Titanium seem to be absent in the Nspire.

Porting TI-BASIC programs from Nspire to TI-89 Titanium

The BASIC on Nspire and TI-89 Titanium are highly compatible. Most function calls and control flow structures are almost identical. Some exceptions are

  • Names for variables and programs are limited in length of 8 characters on the Titanium.
  • setMode method required string type on the Titanium, even if they are integers for both version. The parameter sets and the corresponding values are changed in Nspire. For example, setting Radian mode in TI-89 is setMode("3","1"), while in Nspire it is setMode(2,1)
  • count method that return number of elements in a list is missing in the Titanium version of BASIC.

Porting program from Nspire to Titanium should be 99% copy and paste task using the TI Connect Program Editor on PC. This program editor is a must-have tool to free us from the tedious chore of punching code on the limited Titanium keypad. Although the Nspire is equipped with a nice alphabetic keyboard, when doing programming work with it I do still prefer using its PC software. The calculator keyboard does make life easier to program on-situ, as well as recalling variables. Below is a screen showing a program ported from Nspire for running the Nelder-Mead algorithm.

ti89nm1nspirebasic1

Although the monochrome Titanium screen looks ancient by today’s standard, it was once one of the most advanced calculators on the market when it was introduced 10 years ago, when 3D graph plotting on graphing calculators is a luxury – despite the wait time and low resolution wire frame display. Below is a plot of the Rosenbrock function used to test the program ported from Nspire.

ti89nm2

And here are some figures on the performance running a benchmark program of the Nelder-Mead algorithm on the Rosenbrock function.

0:22 Nspire at 246MHz
0:41 Nspire at 132MHz
1:49 TI-89 (on emulator) running at 250%CPU
1:55 TI-89 (on emulator) running at 100%CPU