Posts Tagged ‘Tutorials’

Awesome seminars at UW

April 3, 2012 1 comment

There are some fascinating seminars sponsored by UW, and most of them are recorded:

CSE Colloquia:
Every Tuesday 3:30 pm

Yahoo! Machine Learning Seminar
Every Tuesday from 12 – 1 pm

UWTV: Research/Technology/Discovery Channel
Broadcast all the new findings, research, technology for free!!




How to Install Eclipse and Android SDK on Ubuntu 10.04 LTS

January 17, 2012 1 comment

Before walking you through the installation process in details, it’s good to know a big picture:

  1. Since Android development needs Java, so we are going to need Java installed on Ubuntu
    • If you are using 64-bit Linux machine (e.g. 64-bit Ubuntu), you may need to install ia32-libs.
  2. You will also need Java Development Tools (JDK), and Eclipse is recommended
  3. The last thing is to install Android Development Tools (ADT) on Eclipse

All the information regarding the installation can be found at the Android developer website

Here is the installation in details:

  1. Install Java
    1. If you are using 64-bit Ubuntu, you will need to install ia32-libs package:
      sudo apt-get ia32-libs
    2. Next, install Javasudo apt-get install sun-java6-jdk

      A tricky part is that when the Java installation almost done, you will need to click <Ok>, which can be done by click in the terminal and press Tab until the <Ok> is highlighted.

  2. Next, you will need to install Java Development Tools (JDK). Eclipse is recommended because there is an Android Development Tools (ADT) plugin available.
    1. Go to
    2. I download Eclipse IDE for Java Developers (both 32- and 64-bit are available)
    3. Extract the downloaded file eclipse-java-indigo-SR1-linux-gtk-x86_64.tar.gz, and you will get the folder called eclipse, containing all necessary files
    4. Since Eclipse is built to be portable, you can move the extracted eclipse folder to any location you want. It is recommended to move the file to your home directory /home/yourusername/
    5. You might want to add the launch icon on the menu, please follow the process here.
  3. Launch Eclipse, we will now install the ADT plugin
    1. go to Help>Install New Software..
    2. According to the ADT plugin page, we will put the URL
      and click Add
    3. Tick the newly added plugin, and click Next until done
  4. Next, we will install Android software development kit (Android SDK)
    1. Download the Android SDK from
      For (both 32- and 64-bit) Ubuntu, you will download android-sdk_r16-linux.tgz
    2. Extract android-sdk_r16-linux.tgz in the home folder (/home/yourusername/)
    3. The extracted folder is android-sdk-linux
    4. Now go back to Windows>Preferences
    5. On the left panel, click Android
    6. In the SDK Location, select your extracted SDK location, which is
    7. Click Apply and OK, wait a few minutes for the program to update
  5. Retrieve all necessary files for SDK
    1. Go to Window>Android SDK Manager
    2. Tick all the Android versions that apply, and click Install packages
  6. Done, So now you may proceed to build a new project!!!

Additional reading can be found from

Solved: pdfExpress verification gives some errors

August 5, 2011 Leave a comment

My paper did not pass the pdfExpress verification due to the error:

Error Font Helvetica is not embedded (111x)

Here we follow the process from the submission homepage:

If you are using the conference template in its Winword version and still get errors (or no answers) from pdfExpress, try this procedure:
1) Please check the top margin of the the first page. it MUST be 2.5 cm; for OTHER pages it must be 1.9 (cm)
2) Generate the pdf file
3) Then you have to embed the fonts. You can do that either
3.1) by using acrobat professional or
3.2) using the line command

gs -dSAFER -dNOPLATFONTS -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sPAPERSIZE=letter -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -sOutputFile=OUTPUT.pdf -f INPUT.pdf

where INPUT.pdf is the pdf source file, OUTPUT.pdf is the output file to be submitted with the fonts embedded and gs is the ghost-script executable command.
If this does not work, or you have other pdfExpress problems, please contact Dr. Romolo Camplani at

However, after trying such a method, the pdf is rejected from the submission website. So, we still have to put the output file to pdfExpress to verify again, and of course you can now expect no error. Then you can proceed to submit the pdfExpress-verified pdf to IJCNN, and the file is PID1839743.pdf whose content is identically the same as ClosedFormDcsGMM_IJCNN_final_added2.tex.

How to remove white-border from a figure?

August 5, 2011 Leave a comment

When adding a figure to your publication, you might want to remove the undesired white-border off your figures. I believe that the best way is to create figures without the border if it is possible. In MATLAB, I think you can do so. However, if you have the figures already, you might want to have a program to remove the borders automatically, wisely and controllably. I developed a toolbox in MATLAB for this purpose. Please refer to the URL below.

The overview of white-border removal toolbox

Plot 3D ellipsoid

August 4, 2011 1 comment

Plot 3D Gaussian distribution? The harder part is to plot the 3D ellipsoid which can be done by calculating the axes (radii) of the ellipsoid from its eigenvalues. Simultaneously, We will get its corresponding eigenvectors which tells how to rotate the ellipsoid. The function ellipsoid(.) can plot canonical ellipsoid, and hence we need to rotate the canonical ellipsoid using the eigenvectors. That is it. Here are some codes adapted from Rajiv Singh’s version.

% plot 3D ellipsoid
% developed from the original demo by Rajiv Singh
% 5 Dec, 2002 13:44:34
% Example data (Cov=covariance,mu=mean) is included.

Cov = [1 0.5 0.3
       0.5 2 0
       0.3 0 3];
mu = [1 2 3]';

[U,L] = eig(Cov);
% L: eigenvalue diagonal matrix
% U: eigen vector matrix, each column is an eigenvector

% For N standard deviations spread of data, the radii of the eliipsoid will
% be given by N*SQRT(eigenvalues).

N = 1; % choose your own N
radii = N*sqrt(diag(L));

% generate data for "unrotated" ellipsoid
[xc,yc,zc] = ellipsoid(0,0,0,radii(1),radii(2),radii(3));

% rotate data with orientation matrix U and center mu
a = kron(U(:,1),xc); 
b = kron(U(:,2),yc); 
c = kron(U(:,3),zc);

data = a+b+c; n = size(data,2);

x = data(1:n,:)+mu(1); 
y = data(n+1:2*n,:)+mu(2); 
z = data(2*n+1:end,:)+mu(3);

% now plot the rotated ellipse
% sc = surf(x,y,z); shading interp; colormap copper
h = surfl(x, y, z); colormap copper
title('actual ellipsoid represented by mu and Cov')
axis equal

Simple Classification Models: LDA, QDA and Linear Regression

July 28, 2011 Leave a comment

Finally, my website was set free from the hacker–at least for now ^_^. In my backup directory, I found some notes I made for the Pattern Recognition class I taught in Spring 2010. The notes contains the details of the derivation of

  • Linear Discriminant Analysis (LDA) and Quadratic Discriminant Analysis (QDA) [pdf]
  • Linear Regression for Classification [pdf]

Hope this can be useful.

Using recursion in MATLAB

July 25, 2011 Leave a comment

This week I wind up with coding sum-product algorithm in MATLAB. All went well, and there were some interestingly simple but powerful techniques I would like to share. We all know that programming function with recursion can save a lot of time, and is a classic technique in C++. I just realized that we can do so in MATLAB too, and the way to do it is very similar to that in C++.

Example1: “Calculate the summation at each node in a binary tree”

I have a 3-level binary tree whose nodes are connected as follows: node1 is the parent of node 2 and 3, node 2 is the parent of node 4 and 5, node 3 is the parent of node 6 and 7. Let’s assume that nodes 4 – 7 are instantiated with number 4, 5, 6 and 7 respectively. We want to calculate for a node n the summation of its corresponding children in the leaf level. Let’s name the function fn_recurs_sum_tree(tree, n) where the variable “tree” is the binary tree structure with node 4-7 instantiated as above, and n denotes the node of interest. More specifically, tree is a cell array of the size 7 x 1, where tree{n} returns the value stored in the node n of the tree. Here is the example of the code

function sum = fn_recurs_sum_tree(tree,n) if ~isempty(tree{n,1})     sum = tree{n,1}; else     sum = fn_recurs_sum_tree(tree,2*n) + fn_recurs_sum_tree(tree,2*n+1); end 

Example2: “Calculate the summation at every node in a binary tree”

What if we want to find the summation at every node in the network? Of course, we would not call the function fn_sum_bin_tree(tree, n) for n=1, 2 and 3 as that would not be efficient when the number of node is large. One technique is to call the function at the root node (i.e., n = 1) so that all the summation is accumulated from bottom to the top. The price to pay is to deal with how to pass the cell array tree into such a function. Here is the example.

function [sum, tree] = fn_recurs_sum_tree2(tree,n) if ~isempty(tree{n,1})     sum = tree{n,1}; else     [sum1, tree] = fn_recurs_sum_tree2(tree,2*n);     [sum2, tree] = fn_recurs_sum_tree2(tree,2*n+1);     sum = sum1 + sum2;     tree{n,1} = sum; end 

Here are some test codes:

% #### example code ######
% initial the tree
tree = cell(7,1);
for n = 4:7
    tree{n,1} = n;

% Calculate the sum for a single node 2
sum = fn_recurs_sum_tree(tree,2)

% Calculate the sum for the whole network
[sum, tree] = fn_recurs_sum_tree2(tree,1)

This technique is very useful when you have to deal with tree. So, hope this helps! Sample codes are made available here:


Just copy all the codes, put them in the same folder, then run example1.