Computer Scientist

Sunday, 6 March 2011

Mean, Median, Mode (Averages) and Range

How to find a common statistical number is a crucial part of post-experiment data analysis. However, too many notations would pop into our mind if we start to carry out the data analysis. I searched across the whole Internet and tried to find all of the useful notations in this field. And I will also extend to other formal literatures in the future.

Mean: add up all of the numbers and divide by how many numbers there are.

Median: put the numbers in order and find the middle number.

Mode: the most common number.

Range: the difference between the biggest number and the smallest number.

Thursday, 24 February 2011

Usefule Linux Commands:

Kill all of the specific process:

killall -9 <command name>

This is different a little from UNIX, BE CAREFUL!!

Saturday, 19 February 2011

Found a Bug in jBittorrentAPI

Actually, this is my first time to find some bugs in other's work.....

In it's TorrentProcessor class, it get the value of file length using a Long.inValue. The precision has been lost a lot, even if it assign it back to a long value. Because of this bug, I got a overflowed number with minus to be inserted into mysql's unsigned big int column!! Obviously, a error message is obtained.

Actually, the reason that I will use this package is that, it can read all of the files that C version's bencode program can not read. Whenever I process the files from Pirate Bay, there would be a segmentation fault sent back to me.

Good work for jBittorrentAPI.....

Change table properties in MySQL::

The most basic one is :


ALTER TABLE person MODIFY person_id SMALLINT UNSIGNED AUTO_INCREMENT;



More detailed can be found here:
http://dev.mysql.com/doc/refman/5.1/en/alter-table.html

What if you encounter an error message of "out of heap" in Java?

At this time, you need to:
 (1). check the program and find out any possibility to free the unnecessary resource.
 (2). increase your heap size to achieve more memory allocated to java.

Here I only care about the later one:

java -Xms<initial heap size> -Xmx<maximum heap size>
Defaults are:
java -Xms32m -Xmx128m


                                    

Usage of u_int32_t and size_t

Actually, the usage of these kinds of types confused me for a quite long time, because I really don't know what's the differences between these types and the C's primitive types such as 'int'?

The C's primitive types such as 'long', 'int' are machine dependent, which means different types system probably has different definition of long and int. For example, in old x86 (486), 'int' may be defined by 2 bytes. However, it is 4 bytes in most machines nowadays. In this case, 'u_int32_t' or 'int32_t' is invented to be a system independent type. In fedora, they are defined in file '/usr/include/sys/types.h', 'u_int32_t' is only  possible to be a 'int' type with 32bit (4 bytes). This will provide the program with being portable.

Friday, 18 February 2011

Experiment Q&A............

When I compiled the lookup program using MySQL connector C++ statically:

Q: what if I am confronted with "ld: can not found lm "?
A: The reason is that 'ld' can not find the static version of 'libm.a' within the default position.
     So I need to install it in Fedora using yum: "sudo yum install glibc-static". This should solve the 'lm' problem.

Q: what if I am confronted with message: "undefined reference to 'pthread_self' and so on...."?
A: The problem is that the pthread library can not be found. Just direct the g++ the location of it by append "-lpthread" at the end.

Q: What is the command that I used to compile the program and link against the static library?
A: Like this: "g++ -static -o <dst> <src> /usr/local/lib/libmysqlcppconn-static.a /usr/local/mysql/lib/libmysqlclient.a -lpthread".

Q: When using the static library, sometimes there is a strange message pop out: can not found lc ?
A: Because the static version of glibc is not installed by default, we need to install by ourself:
        sudo yum install glibc-static