Monthly Archives: March 2016

Micro SD card performance with different adaptor

There are several way to connect a micro SD card to a PC. The most popular being a versatile USB card reader that is capable to read different storage media. There are also built-in card reader on notebook computer.

Since the Android phone supported USB external media via OTG interface, there is a new kind of micro SD adapter on the market that work with both mobile device and PC, and are made very compact like the one on the right below.


To compare whether there will be difference in access speed, a simple test is performed using CrystalDiskMark with the two adapter devices above. Three groups of 10 sample read data (an internal SD reader of a notebook computer, a standard USB interface, and a USB 3.0 interface) are collected for the same micro-SD card which is a SanDisk 32GB class 4. The data are analysed using the ANOVA function available on the TI-84.

Looking at the p-value, there is a significant difference between any of the mean reading speed.

Simple Excel conditional RAG icons comparing yearly fluctuations

The conditional icon set in Excel is a great feature for visualizing data values. A simple usage will be showing up / down arrows in red / amber / green color. In its default Excel will do the calculation across the cells to determine which icon to use. This is nice but for some other usage it might be necessary to have some customization and it can be achieved with the respective Conditional Formatting dialog. For some usage, however, the restrictions imposed in this dialog like relative reference prohibited the presentation of certain commonly used intuitions.

For example, the data below depict sales value country-wise. Using automatic icon set in defaults, Excel will not present the desired icons in the way of showing sales moving up or down for each country, but instead it will show the icons by the yearly value.


A simple solution is to add a calculation column using the if() function to return either -1, 0, or 1 corresponding to the sales value comparison by country. The auto formatting icon can then be applied to this column. With a final touch of column width setting, the result is nicely presented.


Moving average calculation on scientific vs financial calculator

The idea behind moving average is very simple. It used to be quite cumbersome for older generations of calculator to do this sort of calculation. With modern models, this is a piece of cake as the List feature is almost becoming a standard feature.

For the popular TI-84 series, the list feature can be used to store values into variables. Not only can the list be named, the name assigned can also consist of multiple characters. With the list defined, the moving averages can easily be calculated with arbitrary parameters.


On the financial model arena, the HP17bII+ is a special breed alongside its popular and successful line of signature financial calculator HP12c. The manual for the 17b provided an example that make use of the built-in solver for this. The menu driven 17b is quite convenient to use.


Solving a primary school math problem with Excel Solver

Since the last installment with a controversial primary school mathematical question, another interesting but no less challenging question is being popularized recently on local social media. The question involved finding the value of 9 single digit variables, namely A to H and P, that will fulfill the following simple calculation, where A to H are all of different values, and


As reported in local newspaper, this question originated from a primary school for provoking student’s mathematical thinking and is not in standard syllabus. Yet it is challenging even for university graduates.

It is not the intention here to discuss the pedagogy of this problem, but only to explore solving this interesting problem using Excel without any programming.

The Excel Solver is able to solve this question by modelling it into constraints. Usually for Solver problems the variables are modeled in single cell values, but since this question mandated some intrinsic properties that are not easy to be defined in the Solver dialog, a special matrix is used instead of single cell value like in the below so that constraint of each variable carries different value can be defined.primarydifficultexcel1

The various constraints are modeled in the Solver dialog. Each sum of row must be one implies only one digit is selected for each run for A to H. Likewise each sum of column must be equal or less than one implies no duplicate digits for each run. Integer constraint is also applied. The target cell containing the equation of PPP – (AB – CD + GH) is set to zero. Simplex-LP method is selected for this problem, while it was believed that evolutionary methods better suit the model as the matrix has high resemblance of genes.

Running the Excel Solver to obtain the result. On an Intel Core i5 it took almost 2 seconds!

A more descriptive diagram showing the relationship between cells that the model is comprised of. The column next to the Sum of row one are sumproduct cells that will naturally return the values represented by each variable according to the selected single digit value.


Excel file download

The Excel Solver is not just versatile but also is fun in itself to work with tricky problem like this “primary school” question.

Stochastic Gradient Descent in R

Stochastic Gradient Descent (SGD) is an optimization method common used in machine learning, especially neural network. The name implied it is aimed at minimization of function.

In R, there is a SGD package for the purpose. As a warm up for the newly upgraded R and RStudio, it is taken as the target of a test drive.


Running the documentation example.

Running the included demo for logistic regression.R-sgd3

Upgrading R and RStudio

Although the old version served well, it is still nice to see these two brothers getting upgraded.

The RStudio is upgraded first.

sudo apt-get install gdebi-core
sudo gdebi rstudio-server-0.99.891-amd64.deb

For reason unknown to me the R came installed is an very old one (back to 2013). So a more recent R is installed manually. The following commands will stop RStudio for the upgrade (and the last one to restart).

sudo rstudio-server offline
sudo rstudio-server force-suspend-all
sudo rstudio-server online

However, for my installation that does not work. The thing that worked is log in to RStudio and then use “Session > Restart R”.

A fresh start of R / RStudio!