Class#1: Intro to Discrete Mathematics

I figure this is a good way to review class note, and I will try to write an entry as frequently as possible.

Discrete mathematics: problems over natural numbers, and natural numbers are anything from zero to infinite positive integers.

Discrete mathematics is relatively a new course in computer science. Fairly a decade or two ago, students have to study all the components of discrete mathematics separately, so there will be a class for graph theory, abstract algebra, number theory and logic.

The followings are the topics will be discovered in today's discrete mathematics course:

1. combinatorial

This is one of the most fundamental studies of computer science, as simple as just counting numbers, or method of counting. It includes permutation, combination and binomial theorem. It may seems elementary but combinatorial applications are extremely difficult.

Let us consider this case. A computer scientist is asked to study and create a new network system for Verizon (a national-wide telephone company), and the figure below is his draft. A challenge is to detect failure of any point. A complex algorithm must be written for this task, and a computer scientist will need to find out how many ways can this failure occur, method of detection, and such.

Sometime, for a computer scientist, it can be a disaster if the method of counting grows at an exponential rate (try to compute 100, you get power of 43). For most real world application, combinatorial results usually generate millions results, it is very important that one knows how to optimize the calculation.

Combinatorial application, can also be as simple as lottery. Choosing 5 numbers from 1-56, and a number from 1-46, will result in C(56,5) x 46 ~=(approx.) 180 million chances (0.18 billion).

With coding theory and computer language theory, "string" is also studied in combinatorial application, which is treated as linear arrangement. For both computer science and computer engineering major students, combinatorial is very important.

(more...)

Google is leaving China

Yesterday Google's Corporate Development and Chief Legal officer, David Drummond wrote an entry on his blog, announcing that Google would withdraw its business from China, if the two parties' negotiation fail.

Political censoring has hindered Google from competing against China-native search engine Baidu. Google sounds threatening and this withdrawal may cost both parties billions of dollars of lost. If negotiation fails, Google will probably re-locate its Asia business strategy to Taiwan.

http://googleblog.blogspot.com/2010/01/new-approach-to-china.html

A sticky note for Ubuntu installation

gcin

http://cle.linux.org.tw/trac/wiki/GcinDistros

1
im-switch -s gcin

ShowTime theme

1
2
3
4
5
gpg --keyserver hkp://keyserver.ubuntu.com:11371 --recv-key 881574DE && gpg -a --export 881574DE | sudo apt-key add -

sudo gedit /etc/apt/sources.list
deb http://ppa.launchpad.net/bisigi/ppa/ubuntu jaunty main
sudo apt-get install showtime-theme

Emacs, checkGmail

1
2
3
sudo apt-get install emacs
sudo apt-get install checkgmail
checkgmail -update

Python 101: Intro to Python

Most tutorials start with installation, and write a simple program called "Hello World", I will follow this tradition just to make sure we cover the basics. Then I will move into control structures and some basic OOP, because almost everything we do in Python is OOPs.

Where to get python?
http://python.org/download/ and get whichever version you want, either 2.6.4 / 3.1.1 (at the time of this writing)

2.6.4 vs 3.1.1, which one?
It gets very technical when one is asked to explain the difference. Here is the shortest and simplest version:

Go with 2.X branch because 3.X branch has a lot of changes, and many existing books, codes and resources are written based on 2.X, so you are better off learning 2.X branch.

If you are very serious about learning Python, you will be happy with 2.X and then learn the differences later.

Write Hello World

Just like any other modern programming language,

1
print "Hello World"

Notice that, unlike C++, Python does not end with semicolon ;

Hack Python Program

As an beginner, you are better off hacking programs, rather than writing the entire program yourself. Once you understand what each line means, then you can write your own program. For example, just change the values or words around.

Unlike complex language like C++, Python is very simple, yet elegant. You do not always need to declare and define types and identifiers.
When we assign a number to any variable, Python knows it is an integer by default. When it is within double quote "", Python knows it is a string.

1
2
abc = 1
cde = "What"

When you need floating point and other numerical types, then, yes, you do need to specify it. So use the option when it is mandatory.

Here is the major difference between the 3.X and 2.X. By default (2.X) if you do 3 divide 5, you get ZERO, whereas in 3.X you get an answer with demicals. If you are using 2.X, you must add one decimal point to any one of the numbers. For 3.X, you are no longer require to declare this extra decimal, because by default 3/5 will print a rounded answer.

1
2
3
4
5
6
7
8
9
10
11
IDLE 2.6.4      
>>> 15/2
7
>>> 3/5
0
>>> 3.0 / 5
0.59999999999999998
>>>
>>> 3/5.00
0.59999999999999998
>>>

Another way is to declare it a floating point, and round it up (check doc / google for answer).
(more...)

New Year 2010!!

Welcome 2010 !!!

LOL I am tired of reading "Happy New Year" every year on AIM and Facebook. I do not celebrate New Year eve for a few years already because I am not a kid anymore.

A new decade!!

Yeah, it's 2010, another decade since 2000. So what? Just stay home, like we never had a new year before.

I have a boring life now. I really need some works to do over this break. I have a planned agenda before the break, but I am procrastinating. Oh my god, I need stop it.

Oh, I am reading Rainie Yang's bog recently. Her latest entry 心.煩... is here. Her blog says a lot about her life. I have read a few other artists' blogs before, yet, I find Rainie's one frankest, especially with her emotion state. For numerous times she mentions that she wants to be in love.

I start learning about the true face of Rainie Yang through various sources: drama, blog, news and interviews. At 娛樂百分百, she interpreted her new song "青春鬥" how she felt as being 25 years old. She said only love could keep her young. As an actress, as well as a star, she could not have an open relationship. She has at least five known love affairs and the only one she ever admitted was with 小鬼, whom was her first boyfriend in high school, and whom she thought she would marry with. Nevertheless, her parents' divorce had her lost faith in marriage and love. A week ago she told the reporters that she was still single, but she felt she was "in love" for the past couple months. She was referring to her role in Hi My Sweetheart. She once admitted that she wanted to be in love, but she would not promise because she could not.

Oh well, it is my time to sleep. I wish everyone has a great starting.

I am really bored without Hi My Sweetheart !!!! >3<

Got my room already

After a few months of efforts, I finally got a room near school. It is right across the main campus, about 30 seconds away from the gate. I am very happy with it.

As I have mentioned before, I would share this room with a visiting phD Columbia student from Beijing. Nevertheless, the room is large enough to fit two people, enough space to sleep and work. The basic rent is $720 per month, shared by the two of us. Utility is electricity, and is shared among the four of us, probably between $20 - $30. To round up the total cost, $360 + $40, I am expecting $400 per month per person. This is not bad at all.

I will move in mid-Jan, probably around Jan 10 - 15.

I am looking forward with Hi My Sweetheart ep.10. Oh my god.

Anyway, tomorrow is December 31th, but I am going to stay home. It is too cold to join the crowds at Time Square tomorrow night. Oh well. I am still waiting for Ross to review my grade. I can't believe he gives me B+. My final project deserves an A.

Oh today the NYPD had an investigation near Time Squares because of a suspicious white van. By noon they found the van safe, with only clothes and tables. Man, terrorism is really bad-ass. Ruin people's life.

Si-tu-but seems to be ill today. I hope she gets well soon. <3 I love my hamsters.

Hi My Sweetheart (海派甜心)

Oh my god. I am in love with this drama. I can't stop thinking about the characters and story. It is a really cute drama fantasy. I even image-cut a scene when she cries to her pink tiger doll, and makes it my AIM default.

#

Rainie Yang is really cute, and her acting is mature and good in Sweetheart. For the last few years, I refused to watch her drama for some unknown reasons. Nevertheless, I find her a good actress in Sweetheart.

I remembered her from Meteor Garden. I was surprise to find out that she was a former member of 4-In Love at age of 16.

Rainie is now 25, and is getting older. Yet, I find her now more attractive. She has femininity - I just like how she is now. Pure and lovely.

I know she has makeup on, Mike. But in my opinion I think she still retains at least 60% - 70% of her beauty without any makeup. I am serious.

Hi My Sweetheart is hilarious. I laugh to death for every 5 minutes. They make the love scene funny too. I am looking forward with ep 10 next Sunday.

I dream that I will find a girl like Chen Bao Zhu (寶茱姐). She is not rude, just very independent and assertive.

Fisher-Yates shuffle in python

As I was writing a simple lottery program for TVBoxNow, I was wondering how module random actually worked. I wanted to write my own random module, but it turned out the mathematical philosophies were beyond my calculus knowledge. It was probability and probably also had to deal with linear algebra.

Great people from Stackflow had provided a lot of insights and useful links. There was a brief overview of what Fisher-Yates shuffle on Wikipedia.
Fisher-Yates shuffle

Mersenne Twister

It turns out that Python's random module implements Fisher-Yates shuffle and Mersenne Twister methods. Not exactly the same, of course, there are changes made for better optimizations and greater unbiased result.

1
2
3
4
5
6
7
        # only run this loop from 0 to 19 (20 times)
        for player in range(20):
            num_player = len(lst_shuffle) # get the total numbers of players
            k = random.randrange(num_player)
            random.shuffle(lst_shuffle,random.random)
            print player, lst_shuffle[k], "random:",k
            del lst_shuffle[k]

Additional Reading: The Fisher‐Yates shuffle algorithm

I was wondering why there is an optional random.random() function in the end (I know it's optional). Here was a statement I found from the additional reading:

Pseudo random number generators
Most, if not all programming languages have libraries that include a pseudo-random
number generator. This generator usually returns a random number between 0 and 1 (not
including 1). In a perfect generator all numbers have the same probability of being selected but
in the pseudo generators some numbers have zero probability.

Christmas Eve? Hungry.

Yes. Christmas Eve already. Happy Christmas.

Nevertheless, what I really want to do is work. Well, actually, I want to eat first, but my refrigerator is empty.

So I have been looking for a room near City College for two months already. I have visited one, which is only two blocks from City and with utilities I am expecting $550 a month. The landlord is a nice lady, but I really want to minimize my expense.

After spending more than a thousand dollar on Wendy last year, I am really broke. I did have a summer job and it was quite good bonus. Two months ago I decided to save all my money into my bank account, and I have $2200 left.

A Columbia PhD student spoke to me if I would share a room with him, between $600 - $700 a month. The deal is that if we divide it half, each of us will only pay $300 - $400. Although I always hate sharing a bedroom with another person, I guess I just have to learn it since MIT and Cornell only provide shared dormitories.

After speaking to an admission staff at Cornell, since I have course conflict this year, I would have to apply as a junior standing. For MIT, it's worth a try this year, just to get the experience. To get admitted to MIT, one must demonstrate its unique potential contribution to MIT community, and I already have a concrete idea about what I need to do. It's worth that $70 this year and next year again.

Double standard!? phpBB4

I am very disappointed with phpBB team. Their team members are so double standard. While their own people proposing feature implementations, and have no problem with those, they would warn users not to jump ahead the schedule.

While there is no specific restriction or vision what they want since the beginning, they police my thoughts and ideas. I am totally sick of their tones and attitude. I was the first one asked people not to draw any tangent, and later they came back to lecture me.

What a shame to these experience software engineers. I am only a freshman in college, and I find myself a better engineer than they are. They tell users their expectations implicitly. They want to discuss archeiture, then please have the developers start the discussion first. Users' engineering experiences do not matter at all. It is about correcting the attitude.

They make users uncomfortable to give in. Users are penalize when their comments offend the developers even if they are facts. They police users' thoughts and ideas. I agree that we need to monitor every reply and to keep our discussions relevant to the subject, however, phpBB team does not let users know their expectations.
(more...)

Page 1 of 3312345»102030...Last »