Archive

Archive for May, 2009

Difference between Chinese and other

May 28th, 2009

Author: Xu Cui Categories: fun, life Tags:

Adobe Flex 3 Component Life Cycle

May 21st, 2009
Author: Xu Cui Categories: adobe air Tags:

Tips for writing faster MatLab programs

May 19th, 2009
  1. Avoid using explicit loop if possible
    %calculating the sum of the product of corresponding element in two row vectors A and B
    %bad example
    s = 0;
    for i=1:100
    s = s + A(i)*B(i);
    end
    %good example
    s = A*B';
    
  2. Avoid increment memory allocation, instead, try allocate memory first
    %bad example
    s = [];
    for i=1:10000
    s = [s some_number];
    end
    %good example
    s = zeros(1,10000)
    for i=1:10000
    s(ii) = some_number;
    end
    
Author: Xu Cui Categories: matlab Tags:

phpBB 3 spam filter

May 18th, 2009

Standard phpBB captcha is broken. I modify it such that the user need to add the numbers in captcha images and enter the result (e.g. 1+2+3=6), instead of enter the original characters (e.g. ‘123′).

Enter folder /includes/ucp

edit file ucp_confirm.php: around line 75, find $captcha->execute($row … ) and change to $captcha->execute(’123′,…)

edit file ucp_register.php:

around line 191 (’confirm_code’ = > …), change the mimum # of characters to 1 (instead of 5).

around line 489, find $code = gen_rand_string(mt_rand … and change to $code = ‘6′

Enter folder /

edit file posting.php: around line 755, find line if(empty($confirm_row … and change $confirm_row['code'] = ‘6′

Enter folder /language/en/common.php, change ‘CONFIRMATION_CODE_EXPLAIN’ strings to ‘Add all the numbers and enter the result’

Author: Xu Cui Categories: linux, php, web Tags:

Badminton: Lin Dan vs Lee Zong Wei

May 17th, 2009

Author: Xu Cui Categories: fun, life Tags:

no tissue paper

May 14th, 2009


Original Video- More videos at TinyPic

Author: Xu Cui Categories: fun, life Tags:

AdaBoost, Adaptive boosting

May 12th, 2009

AdaBoost is an algorithm to linearly combine many classifiers and form a much better classifier. It has been widely used in computer vision (e.g. identify faces in a picture or movie). Look at the following example:

How it works?
First, you have a training dataset and pool of classifiers. Each classifier does a poor job in correctly classifying the datasets (they are usually called weak classifier). Then you go through the pool and find the one which does the best job (minimizing classification error). You then increase the weight of the samples which are wrongly classified (so the next classifier has to work better on these samples). Then you go through the pool again. Formally, it is (click to see a larger view):

(From http://cmp.felk.cvut.cz/~sochmj1/adaboost_talk.pdf)

Now let’s try it. In the following example, our data is nonlinearly separated. In our pool of weak classifiers, they are all dummy (can only classify with a single threshold on a single data dimension). We repeat 10 times (i.e. find 10 weak classifiers) and combine them to form a super strong classifier.
Original dataset:

Better and better super (strong) classifier when more and more weak classifiers are incorporated (click to see a larger view). t means the number of weak classifiers included.

The error rate is decreasing as more and more weak classifiers are included:

Here is the source code:
example.m example
weakLearner.m weaklearner

Author: Xu Cui Categories: matlab Tags:

24 Hour World Air Traffic (Fast Version)

May 9th, 2009

Author: Xu Cui Categories: life Tags:

Distribution of correlation coefficient (r)

May 6th, 2009

Assume you got correlation r=0.6 between two variables (N=10), is 0.6 significantly bigger than 0? Or if you observed r=0.98, is it significantly different from r=0.9? For these questions, we need to know the distribution of r of our sample, given the population correlation coefficient ro and sample size n.

This distribution is complicated:

For more info, you can find from the link at the bottom. But let’s plot some distributions for different ro and n:

Then, you can simple calculate the area under the distribution curve to find the p-values.

Link:
http://mathworld.wolfram.com/CorrelationCoefficientBivariateNormalDistribution.html

MatLab code for the distribution:

function y = corrdist(r, ro, n)

y = (n-2) * gamma(n-1) * (1-ro^2)^((n-1)/2) * (1-r.^2).^((n-4)/2);
y = y./ (sqrt(2*pi) * gamma(n-1/2) * (1-ro*r).^(n-3/2));
y = y.* (1+ 1/4*(ro*r+1)/(2*n-1) + 9/16*(ro*r+1).^2 / (2*n-1)/(2*n+1));
Author: Xu Cui Categories: matlab Tags:

群众在气功讲座上接”气”

May 2nd, 2009

不熟悉中国八十年代九十年代初的人,可能不知道下面这张照片是干什么的。这是在一场气功讲座上,群众高举双手在“接气”(1987)。我上初中高中时(89-96),学校就很流行这个,校领导也支持,有时还请气功师来。我当时练了严新的九步功法,据说练成之后腹中会产生影子帮你做事。我当然没练成,不然现在就不用做博士后了。当时挺相信这个的,对特异功能有一种渴望。当时老师说,老子可能没有死,后来到山里面去了,我就很相信,认为人有可能活上千岁。

我们学校请的气功师说,我发功,你们的食指会比中指长。学生里真有许多人感觉出来变化了。(可惜我感觉不出来)

Author: Xu Cui Categories: life Tags: