Showing posts with label Geek. Show all posts
Showing posts with label Geek. Show all posts

Thursday, September 9, 2010

数学严重退化了

我一时间居然没法完全理解这个证明。 这完全是个退化标志。
Imagine you are stranded on a desert island (without logarithm tables or computers) and--- probably due to an emotional shock---your only concern is to find out which one among numbers πeand eπ is bigger. The solution is: take h(x)=ln(x)/x, take the derivative twice to prove that x=e is a maximum, and that gives eπ is bigger.

Tuesday, September 7, 2010

Monty Hall problem


Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice?
(additional assumptions that the car is initially equally likely to be behind each door and that the host must open a door showing a goat, must randomly choose which door to open if both hide goats, and must make the offer to switch.)
Simple Solution: "Switch" yields 2/3 probability of getting a car!

Door 1Door 2Door 3result if switchingresult if staying
CarGoatGoatGoatCar
GoatCarGoatCarGoat
GoatGoatCarCarGoat

Thursday, July 29, 2010

Dvorak

I am interested in giving it a go, the programmer’s Dvorak. The best things about it: 1) I can practise my lazy brain; 2) it can serve as a cypher mapping; 3) it sounds geeky and cool. The only bad thing about it: the shortcut keys are not very handy any more.

Instructions on installing and using here:
http://www.kaufmann.no/roland/dvorak/
And a tutorial introducing the layout:
http://gigliwood.com/abcd/

Come, lose and then regain and surpass your productivity with me.

Wednesday, May 12, 2010

Friday, March 12, 2010

Gmap must be a Kayak fan


Sydney NSW
1.    Head north on George St towardsAngel Pl         0.4 km
2.    Take the 3rd left on to Grosvenor St         0.2 km
3.    Continue onto Western Dstr         0.5 km
........
56.    Slight right at Goyder Rd         0.3 km
57.    Slight left at Gilruth Ave         1.8 km
58.    At the roundabout, take the 3rd exit ontoKahlin Ave         0.4 km
59.    At the roundabout, take the 3rd exit ontoMyilly Tce         72 m
60.    Turn left to stay on Myilly Tce         0.3 km
61.    Kayak across the Pacific Ocean
Entering Japan         5,404 km
62.    Turn right towards ??384??         1.3 km
63.    Continue straight onto ??384??         4.3 km
........
121.    Turn right         0.4 km
122.    Kayak across the Pacific Ocean
Entering United States (Hawaii)         6,243 km
123.    Turn right at Kalakaua Ave         0.5 km
124.    Turn left at Kapahulu Ave         2.5 km
........
134.    Turn left at Kuilima Dr         0.8 km
135.    Turn right         0.2 km
136.    Kayak across the Pacific Ocean
Entering Washington         4,436 km
137.    Sharp right at N Northlake Way         1.8 km
138.    Continue onto NE Pacific St         1.3 km
139.    Slight right at Montlake Blvd NE         0.5 km
........
Entering New York         3.8 km
165.    Take the ramp to Downtown/Brooklyn         0.3 km
166.    Slight left at Laight St         94 m
167.    Continue onto Thompson St         28 m
168.    Continue onto Canal St         0.4 km
169.    Turn right at Broadway         0.7 km
     New York, NY

Wednesday, February 24, 2010

FinalYearProject: Encoda and Breacha

Today on the train, I got an idea of making two teams on one colleage final year project. This project has two counteracting parts.
Team A is on Encoda, which encodes English words into out of ordinary but readable pictures.
Team B is on Breacha, which decodes the above mentioned pictures back to ASCII strings.

Put aside the user-interface design, speed, relibility issues etc; the grading stage of the project should be fun: just let the teams compete their algorithms!

Thursday, November 26, 2009

Public toilet capacity analysis

Often you will see a longer queue in front of a female public toilet than its male counterpart. Putting the toilets as server and the users as job, this is a typical FIFO (i.e. first-come-first-serve) server-scheduling problem. Provided that we cannot perform load-balancing (i.e. female users claim male toilet for their use) and we cannot preempt job (i.e. drive anyone out of the toilet during his/her use), the solution is to redesign the capacity of the servers to cope with the estimated job incoming rate.

The model looks like the following. Let's assume there are two urinal pots and two loos in the male toilet; 3 loos in the female one. To execute a urine/poop job, male need 1.5 minutes and 5 minutes respectively; female need 2.5 minutes and 5 minutes respectively. Finally, let's assume that the incoming rate of jobs are on average 4 urinal and 1 poop per time frame for both. This is summarized in the table below.

For male server, it is 5 minutes of execution in both the worst and the best case. For female server, the optimal scheduling yields 5 minutes of execution time (with probability 3x4!/5! = 60%), and the worst case could be 7.5 minutes (with probability 40%). Therefore, on average, the execution time for female is 6 minutes.

How the situation is improved if there is one more loo in the female toilet? The average execution time will be 5.5 minutes. The disparity will be total closed if there are 5 loos in the female toilet.

Further discussion. In reality, there are other causes for female to go to public rest room, for example, fixing makeup, changing sanitary, gossip, etc. They are not taken into consideration here. But those factors are definitely going to affect the capacity of the servers.






ServerMF
Resource2U + 2L 3L
Execution time(1.5M, 5M) (2.5M, 5M)
Incoming rate 4U + 1L 4U + 1L

Thursday, November 19, 2009

Chinese is Object-Oriented Language

There are a lot of articles comparing Chinese and English to some extent. From the computer language design point of view, we shall see that Chinese is an object-oriented high-level language; while English or the like is index-based language.

Let us first look at what is Object-Oriented language. In the computer science, any concrete or abstract thing can be viewed as Object. Objects have their attributes and methods. Take “dog” as an example, color, weight and so on are its attributes; while eating, coquetry, barking etc are its methods.

Similarly, a Chinese character or an English word can also be viewd as an object. Once again, take “狗" (dog) as an example, the pronunciation and spelling are attributes of the word, and its meaning in usage is its method.

The most important concepts of Object-Oriented languages are: encapsulation, inheritance, and polymorphism.

1. Encapsulation

In software engineering, encapsulation means concealing the functional details of an object from its interface. This provides not only certain levels of protection of the data structure, but also excellent foundation for modularity.

The two features of encapsulation are: separation of interface and implementation and the protection of the internal implementation. By the same token, we can define the following four criteria to examine whether a natural language ensures encapsulation.

1. Shape interface: whether all words have consistent shape.
2. Semantics interface: whether there is unique definition of certain words.
3. Pronunciation interface: whether the pronunciation of certain words is unique.
4. Spelling interface: whether the spelling changes according to the different scenario.

Chinese. 1) Chinese characters have squared shape. 2) Most Chinese characters have multiple meanings. 3) Most Chinese characters have only one pronunciation; only a few (more than one hundred) have two or more ways of pronunciation. 4) Chinese characters’ spelling is fixed, despite that there are simplified and traditional spelling.

English. 1) English words can be arbitrary in length. For example, “I” has only one letter; and "pneumonoultramicroscopicsilicovolcanoconiosis" has a total of 45 letters. 2) Most English words have multiple meanings. For example, “book” in noun means differently from it in verb. 3) Most English words have unique pronunciation. 4) Spelling of English words is not fixed. The letters are case-sensitive; nouns have plural form; verbs have tense changes. And the pronunciation will change as well.

To compare them, “do” can appear to be “do”, “did”, “doing”, “done” in English, while in Chinese there is only a need for some commonly used adverb.

Conclusion: Chinese is a better encapsulated language of encapsulation

2. Inheritance

In object-oriented programming, inheritance is a way to form new classes (instances of which are called objects) using classes that have already been defined. Inheritance is intended to help reuse existing code with little or no modification.

For human language, there may not be hierarchies that rise from the inheritance relationship. Still, there are obviously compounds of roots (or 部首) for words and compounds of words for phrase, which make reusing word components possible. We will find that by using inheritance, language is much simpler for learners.

Single inheritance: Chinese characters are mostly made of parts (部首). Some parts are for the semantics (意); some parts are for the pronunciation (音). Therefore, one can guess the meaning of certain words without knowing how to pronounce it, or visa versa. For example, 围、圆、园、圈. These four words all have been circled with “口”; this is for the semantics meaning that they are something to do with circles. The inner parts 韦、员、元、卷 tells how to pronounce them. On the other hand, English has Latin roots that can be used to make words. This can be viewed as an example of single inheritance.

Multiple inheritance: which means to inherit from more than one classes. Chinese language does this in making phrases. For example,
  飞机(plane) = 会飞行(flight)的机器(machine)
  工人(worker) = 在工厂(factory)工作的人(man)
  解放(liberate) = 解开(unlatch)后释放(release)
  计算机(computer) = 能计算(calculate)的机器(machine)

English has such inheritance in the compounded words, such as: football, handwriting, and breakwater. However, there are also very bad examples that no inheritance can be found. For example:
猪 pig 公猪 boar 母猪 sow 小猪 piglet 猪肉 pork
牛 cattle 公牛 bull 母牛 cow 小牛 calf 牛肉 beef
羊 sheep 公羊 ram 母羊 ewe 小羊 lamb 羊肉 mutton
One shall see that there are only seven Chinese characters involved in representing these words: 猪、牛、羊、公、母、小、肉 whilst 15 words for English.

The last example, the months:
  一月 January
  二月 February
  三月 March
  四月 April
  五月 May
  六月 June
  七月 July
  八月 August
  九月 September
  十月 October
  十一月 November
  十二月 December
In Chinese, they are just numbers plus “月” for month. In English, they are twelve irrelevant words.

Conclusion: Chinese language is perfectly inheritance language, (given that five thousand years of Chinese history).

3. Polymorphism

Polymorphism (poly = multiple, morph = shape) is the ability of one type, A, to appear as and be used like another type, B. It provides the runtime flexibility for the language. Actually, polymorphism is a consequence of inheritance. By properly inherited from one interface (a.k.a. abstract base class), values of different data types can be handled using a uniform interface.

To exam whether a human language has polymorphism, we shall see 1) whether there exist words representing interfaces; 2) whether a word in a single interface can have different semantics in its context.

Starting comparison with an example, “我要坐车去” (I will go there by car). In English, it is quite definite that the transportation is “car”. In Chinese, however, “车” is an abstract word; it can refer to汽车 (car), 出租车 (taxi), 公共汽车 (bus), 火车 (train), etc. To be competent in English, one would have to say “I will go there by vehicle” – which sounds odd. Words like “车” that serves as an interface are quite common in Chinese, partly because a lot of compounded words are inherited from some single character.

Another type of polymorphism in Chinese is Pinyin. There are four tones for Pinyin. The tones sometimes are decided within its context, so called “多音字” (multi-tones character). Even the tones are provided, the meaning of the words have to be determined within the context in some cases. For example, “lì hài” can be “厉害” (Formidable) or “利害” (gains and losses, advantages and disadvantages).

Actually in English, the use of the tense is considered anti-polymorphism because the objects (words) changed their interface when its properties are changing; potentially increase the number of objects.

From the above examples, it is quite obvious that polymorphism provides certain degrees of flexibility in communication at the cost of preciseness. This probably is a feature of “information hiding” that makes languages more literally colorful.

To conclude this article, Chinese is, if not the only one, an Object-Oriented Natural Language; and English is definitely not.

Thursday, November 5, 2009

Convert tab-delimited section into a table in MS Word

Just a few clicks, you can convert a tab-delimited section into a table in MS Word:
1, Highlight the section of tab-delimited paragraph (words that separated by tabs)
2, Select menu Table -> Insert -> Table
Done

For example,
A501 MARKETING COMMUNICATIONS Communications NULL
A502 WAREHOUSE/DISTRIBUTION Communications NULL
A503 PHOTOGRAPHY Branding NULL
A504 CONFERENCE/ROADSHOW Branding NULL
A505 INTERNAL COMMUNICATIONS Branding NULL

Becomes

A501

MARKETING COMMUNICATIONS

Communications

NULL

A502

WAREHOUSE/DISTRIBUTION

Communications

NULL

A503

PHOTOGRAPHY

Branding

NULL

A504

CONFERENCE/ROADSHOW

Branding

NULL

A505

INTERNAL COMMUNICATIONS

Branding

NULL



Thursday, October 29, 2009

杂诗一首

怒发冲冠凭栏处
风萧萧兮易水寒
借问酒家何处有
夜半钟声到客船

Monday, September 28, 2009

读博士与坐牢的惊人相似 -- Old Joke

1.都是因为一时糊涂或一时冲动,亦或是对于名利财富的贪婪欲望,错误的选择了这条道路
2.进来先接受教育
3.所有人都分在不同的:读博叫课题组,监狱叫监区或大队
4.必须参与劳动:读博是脑力的(当然也有体力活),监狱是体力的,报酬当然是极少的,基本都是面前糊口
5.里面的人都只有一个目的:早点出去
6.在里面表现好的才可以早出去,当然是极少数:读博叫提前毕业,监狱叫减刑;表现一般的就只有:读博叫按期毕业,监狱叫刑满释放;表现差的只好:读博的叫延期,监狱叫加刑
7.在里面的日子也有不同,读博的如果能遇上个好导师,坐牢的如果能遇到个好管教,生活可能会好过些。反之就要加倍痛苦了
8.中间会有比较猛的家伙实在熬不住了:读博的就直接退学了,坐牢的就越狱了
9.但大多数人只好在里面挨着了,盼望着那天早点到来
10.出去那天的场面是感人的,都要热泪盈眶,迫不及待的冲出去呼吸外面新鲜的空气
11.可好景不长,出去一段时间才发现,在里面待的时间太久,已经与社会脱节,出来后什么都干不了。
12.很多人重操久业了:读博的去申请博士后,坐牢的继续违法犯罪