<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" 
   xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" 
   xmlns:html="http://www.w3.org/1999/html" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
<channel>
   <title>Tung Wai Yip's blog</title>
   <link>http://tungwaiyip.info/blog</link>
   <description>Tung Wai Yip's blog</description>
   <language>en</language>
   <copyright></copyright>
   <ttl>60</ttl>
   <pubDate>Sat, 04 Sep 2010 07:00 GMT</pubDate>
   <managingEditor></managingEditor>
   <generator>PyBlosxom http://pyblosxom.sourceforge.net/ 1.3.2 2/13/2006</generator>
<item>
   <title>Quote of The Day - New York Times on The Mosque</title>
   <guid isPermaLink="false">2010/2010-09-04_quote_of_the_day_-_new_york_times_on_the_mosque</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-09-04_quote_of_the_day_-_new_york_times_on_the_mosque.html</link>
   <description><![CDATA[
<p>There is this controversy about a proposed Islamic cultural center building near the World Trade Center site. I don't feel I should have much of a voice as I'm not a New York citizen. Nevertheless I cannot find any justification in good conscience to oppose such idea. Secretly I hope if there is no controversy to start with it will be easier for everyone.</p>

<p>The New York Times have ran a survey and dismayed to find a full 67% percent say that the mosque should be built on "a less controversial location", a position that betrayed the New Yorker's diverse, tolerant and cosmopolitan identity. Unyielding to public and political opposition, they <a href="http://www.nytimes.com/2010/09/03/opinion/03fri1.html?_r=1">reassert their belief</a> in the editorial. I find it so courageous that I've to quote them:
</p>

<blockquote><i>"<strong>We stand with the poll’s minority</strong>: the 27 percent who say the mosque should be built in Lower Manhattan because moving it would compromise American values."</i>
</blockquote>



]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Sat, 04 Sep 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>Traffic Data Analysis</title>
   <guid isPermaLink="false">2010/2010-09-02_traffic_data_analysis</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-09-02_traffic_data_analysis.html</link>
   <description><![CDATA[
<p>I was doing a traffic data analysis base on the vehicle location data pull from the SF Muni website. This is an extremely interesting project. I pick up a whole lot of new skills while doing this, most notably data analysis and computational geometry. The project also turns out to be a challenging one. A few months (of part time work) has gone by I still haven't nearly achieved my original vision.
</p>

<p>Still I think I am getting better at this work. So I'm sharing some interesting data I'm working with. On one bus route I've collected 20,000 location readings on a single day. The goal is to organize them into individual vehicle trip. After a first pass, the data are reduced to 336 trips. But how good is the quality of data? And how good is my trip segregation algorithm? So I plotted the trips' distance against their duration on a chart. The graph quickly helped me to evaluate the quality of the result.
</p>

<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/38_trips_characteristic.png' alt='Bus #38 trips characteristic' />
</div>
</div>

<p>The first impression is the result looks fairly good. A dense band of points shows that most trip length is about 10 km, and they takes about 40-75 minutes. This seems to match real world experience. At the lower left hand corner is a number of trips that last very short time and cover very little distance. I'll probably treat them as noise and discard them. A curiosity is some trips seem to cover a long distance from 15 to 20 km, much long than the official route. Where did they went?
</p>

<p>Closer examination on their track reveal the problem. These are all legitimate eastbound trips. However the bus starts from a depot in the middle of the city. They went all the way to the terminal in the west end. Only from there the real eastbound trip begins. The challenge for me is I'm only interested in the eastbound portion. The trip from the depot to the west end is actually data pollution. I need to find a way to handle these extraneous data.
</p>

<p>This still leaves a scatter of points of around 5 km long and last 15 to 35 minutes to inspect. Meanwhile I have difficulty to examine the track because Google Earth is crashing on me all the time. I guess this is a good time to turn away from technical work and to write a blog instead.
</p>

]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Thu, 02 Sep 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>The Fall of Hong Kong Entertainment</title>
   <guid isPermaLink="false">2010/2010-08-20_fall_of_hong_kong_entertainment</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-08-20_fall_of_hong_kong_entertainment.html</link>
   <description><![CDATA[
<p>The Hong Kong film industry, once a vibrant and dominant player in the Chinese and Asia cinema, is in a steep decline. It happens that I come across a web entry on <a href="http://baike.baidu.com/view/2619.htm">Jin Yong (金庸)</a>, the most popular and prolific martial art novels writer in Asia. In the entry is a chronological list of all the screen adaptations. Since Jin Yong's novels has been made into TV and movies in regularity, it serves as a proxy to the activity of the entertainment industry. </p>

<p>I have plotted the adaption of each popular novel on a graph, with different colors to differentiate the country of production. The dense chart shows that each novel has been adapted multiple times, sometimes within only a short span of time. Looking decade by decade, you'll see how the pattern has shifted. Jin Yong stories first appear on Hong Kong TV in the 70s. It was the time when most families started to own a TV. 80s is the period when a lot of early and now classic adaptions are made. Taiwan has also started to made Jin Yong stories in this period. 90s continues the frenzy activities. It is also the beginning of decline of the Hong Kong movie industry. The last Jin Yong movie was made in 1994. In 2000s, the 3 decades of restless Hong Kong entertainment production seems to come an end. The last TV made by actors is in 2001 (an animation came in 2003). Instead it is the era of China, where nearly all new productions are now made.
</p>

<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/jinyong_adaption.png' alt='Jin Yong screen adaption chronology' />
</div>
</div>

<p>The filmography is not just a list black and white raw text. It comes to life once we carefully render it into a color graph. And the graph tells a story of the rise and fall of the different players in the industry.
</p>

]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Fri, 20 Aug 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>Wells Fargo debit card transactions lawsuit</title>
   <guid isPermaLink="false">2010/2010-08-15_wells_fargo_debit_card_transactions_lawsuit</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-08-15_wells_fargo_debit_card_transactions_lawsuit.html</link>
   <description><![CDATA[
<p>Wells Fargo Bank is ordered to <a href="http://www.sfgate.com/cgi-bin/article.cgi?f=/c/a/2010/08/11/BU4C1ES0MU.DTL&feed=rss.business">repay about $203 million to customers</a> who were unfairly charged fees in debit card transactions under a court ruling. As a customer of the bank for over 10 years (though I have never been hit by the overdraft charge), I'm really unpleased with my bank's ethics.
</p>

<p>The key scheme works like this. Let's say a customer have $10 in his account. Without a good knowledge the account balance, the customer make multiple debit charges and overdrafted his account. Let says he make a series of transactions in the amount of 5, 1, 2, 3, 11, bringing the final balance to -$12. Instead of denying the charges, Wells Fargo introduced a new feature around 2000 to automatically gives credit to the customer. The catch is each overdraft will cost them a fine of, say, $25. This in itself is not very evil. But what is really enraging is the way the bank manipulate the charges to maximize the overdraft fine. Instead of processing the debit in the order it comes in, the bank rearranged the charges to process them from highest amount to lowest amount order, i.e. 11, 5, 3, 2, 1. In this case all 5 transactions results in overdraft and a $125 fine. If they were processed in chronological order, they fine will be only $50 instead.</p>

<p>The bank insist they have done the right thing for the customers and the customers desire this. Because the larger amount transaction is more likely to be important, therefore it was given priority. Such reasoning is what prompt me to write this blog. It angers me because the bank is offering us a <b>bogus reason</b>. Since all charges are authorized no matter what order they comes in, the customers receive no benefit what so ever from such "prioritization". It would have make a difference if the bank deny the transaction once the account run out of fund. But in the present scheme, the only difference is the amount of fine the customer will incur. It can be mathematically proven that by processing the transaction from lowest amount to the highest, it results in least fine and thus the most beneficial to the customer. Instead the bank scheme to process the transaction from highest amount to lowest, this results in maximum fine and thus results in <b>worst outcome for the customer</b>. There is simply no justification to choose this scheme other than enriching the bank.
</p>

<p>Note that while Well Fargo is the first bank to lose an anti-consumer lawsuit, this is an industrial wide practice. I'm looking forward for other major banks to be exposed and fined.
</p>

<p>After this ruling and addition regulation against such practice preceding the trial, the banks are grumbling on how much revenue they are going to lose and the possibility of stop offering free checking and other banking service to make up for the difference. For me this should raise an alarm on the corporate board level. When your company is deriving a significant portion of revenue from such unsavory source, it is a clear indicator that it is not doing the right thing. It is like opening a gym with free membership, but in fact the true revenue is derived from the vending machine on the floor selling tobacco. Sooner or later pressure will come to maximize profit. Then the company will be mobilized to sell more tobacco to more people. This will become a corrupting force in no time.
</p>

<p>Clearly a company wants to make profit and there is always a pressure to maximize profit. But the question if they earn it because they are providing value to the customer? It is justifiable if they charge for banking services because they are managing my money and dispose them to merchants I authorize to. But the overdraft fee scheme did not provide any value. Instead it is nothing but an exploitation on uninformed customers.
</p>



]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Sun, 15 Aug 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>Confession of A Buddhist Atheist</title>
   <guid isPermaLink="false">2010/2010-08-05_confession_of_a_buddhist_atheist</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-08-05_confession_of_a_buddhist_atheist.html</link>
   <description><![CDATA[
<p>Stephen Batchelor, the author of &lt;Confession of A Buddhist Atheist&gt;, has
articulated he <a
href="http://greatergood.berkeley.edu/article/item/rethinking_buddhism/">feeling
about atheism</a> very well.
</p>

<blockquote><i>nor am I an Atheist, who has a particular axe to grind with God. I’m
not an Atheist in that I have some objection or some dislike of that way of
thinking. It’s simply that I see no use or value of entertaining such notions. I
feel that I can articulate what I believe to be at the heart of my quest for
meaning as a human being without any recourse to such ideas.</i></blockquote>

<p>I can make perfect sense of the world without making any reference to god. I
see no need for me to confirm or deny its existence. I won't call myself atheist
though, as this term is usually associated with the opposition to the concept of
god. I think a better description for me is "I don't care".</p>


]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Thu, 05 Aug 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>Find Sophie Solution (Facebook Programming Puzzle)</title>
   <guid isPermaLink="false">2010/2010-07-22_find_sophie_solution_facebook_programming_puzzle</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-07-22_find_sophie_solution_facebook_programming_puzzle.html</link>
   <description><![CDATA[
<p>This is the fourth and probably my last post about solving Facebook programming puzzle. The <a href="http://www.facebook.com/careers/puzzles.php?puzzle_id=11">Find Sophie</a> problem is a buffet (hardest) level puzzle. It is basically a variation of the traveling salesman problem. Traveling salesman is of course, a NP-complete problem. But before you throw up your hand, consider the puzzle refers to locations in your home where you may find a cat. Just how many locations are there. Let's say living room, dining room, bedroom, on the bed, under the desk, behind the curtain, ... etc. If Facebook is not very wicked, this puzzle should be bounded to a low hundreds of locations. This mean it is still possible to solve using some relatively simple search algorithm.

<p>Here is the outline of my solution:</p>

<ol>
<li>Prepare to enumerate all paths.
</li>
<li>Prefer the local optimal during the search. Remember the best solution encountered so far.
</li>
<li>Prune the search tree. For example if the current best solution has a score of 50. When you are considering another path, as soon as its score exceed 50, you should abandon it.
</li>
<li>Improve the pruning by taking the additional score to complete the path into account. For example, if the current score of a partial path is S, the minimum score to complete the remaining walk is Rmin. Then if S+Rmin > best score, prune it.
</li>
</ol>

<p>Actually I have submitted the solution a few months ago. Only today do I find out I have not posted my solution in my blog. So I'm really speaking from my memory. I hope my plan is still accurate. Again my <a href="/2010/sophie.py">un-tidied code</a> is available.
</p>

<p>The other 3 facebook puzzles I have solved was posted below:</p>

<ul>
<li><a href="/blog/2010/03/03/peak_traffic_solution_facebook_programming_puzzle">Peak Traffic Solution</a></li>
<li><a href="/blog/2010/02/22/refrigerator_madness_solution_facebook_programming_puzzle">Refrigerator Madness solution</a></li>
<li><a href="/blog/2010/02/21/smallworld_solution_facebook_programming_puzzle">smallworld solution</a></li>
</ul>

]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Thu, 22 Jul 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>Highway Network</title>
   <guid isPermaLink="false">2010/2010-07-10_highway_network</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-07-10_highway_network.html</link>
   <description><![CDATA[
<p>Have you wonder why a highway is designed like this? Let's say you are driving from a large city A to a large city B. Between them is a mid size city K. Now city A and B are major economic center and travel destinations. City K is none of that. It is yet another non-descript city. Everyone seems to heading to city B. There seems little reason for anyone to stop in city K.
</p>


<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/highway_network1.jpg' alt='Highway Design 1' />
</div>
</div>


<p>The traffic on the highway was free flowing. Yet as you approach city K, local traffic starts to fill up the highways. the It gets to a point when everything comes to a crawl. You curse at the traffic. Then you wonder why must the intercity highway go through city K at all? Why doesn't it just bypass it so that travelers between A and B can have a smoother trip?
</p>

<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/highway_network2.jpg' alt='Highway Design 2' />
</div>
</div>


<p>I have wondered about this for a long time. Now I have a theory. Roads are built for people. Where there are more people traveling, more investment will be made to build roads. This should make pretty good sense.
</p>

<p>Now which kind of traffic have higher volume? Intercity traffic between A and B or local traffic in K? Despite your intuition that everyone seems to travel between A and B, there are actually more local traffic in city K. This is demonstrated by the fact that traffic is free flowing between A and B but clogged within city K. Therefore more funding will be allocated to build roads for residents of city K and not a bypass. Since intercity travelers are the minority, they will not be better off than the local residents of city K.
</p>

]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Sat, 10 Jul 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>Brief Trip to Shenzhen</title>
   <guid isPermaLink="false">2010/2010-06-30_brief_trip_to_shenzhen</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-06-30_brief_trip_to_shenzhen.html</link>
   <description><![CDATA[
<p>Shenzhen is a major Chinese city adjacent to Hong Kong. It is a vibrant economic power house, home to the Shenzhen stock exchange and many top-tier technology firms. With 9 million residents, its population has surpassed Hong Kong despite its short history of about 30 years only.</p>

<p>Although I grew up next door in Hong Kong, somehow I have never visited Shenzhen (besides using it as a jump off point to other parts of China). Yesterday I have an opportunity to take a dip into the city. It was an unplanned trip. I know nothing about the layout of the city. I have not even bother to purchase a map since it is only going to be a few hours. Instead I just trust my instinct. I jumped on the metro and managed to emerge in the heart of the central business district.
</p>

<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/shenzhen_business_district.jpg' alt='Shenzhen business district' />
  <br />
  Shenzhen Business District
</div>
</div>

<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/shenzhen_upscale_shopping_mall.jpg' alt='Upscale Shopping Mall' />
  <br />
  Upscale Shopping Mall
</div>
</div>


<p>It was more than 10 years since my last visit to China. During the time the economic and urban development of China has make huge stride. I want to witness the extend of development myself. If a cityscape of glass-clad office towers and upscale shopping mall is an indicator, Shenzhen has surely joined the rank of world class cities. The Central City Shopping mall is as good as any great mall in the world. Satisfied with what I saw, I decided to move on.
</p>

<p>According to the map in the metro station, there is a large garden outside of the mall. I set off to explore it. The garden is separated from the mall by a wide boulevard. In order to access it, it seems I have to get on an elevated walkway. But how do I access the walkway?? This has become an unexpected challenge for me. I walk in and out and around the mall before I finally found the unobvious access to the rooftop garden.
</p>


<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/shenzhen_park.jpg' alt='Central Park' />
  <br />
  Central Park
</div>
</div>


<p>The park is an oasis in the large city. It is well manicured with stylish fixtures that any city will be proud of. It is also a great refuge for birds and a delightful place to hear their chirping. There is only one issue though. The park is eerily devoid of people. I mean this is a prime real estate in the center of a metropolitan. Where is everybody? New York's Central Park it is not, all I can see is just a sea of green. Perhaps no one is as foolish as me to go outdoor under midday's summer heat. But I suspect this is not the only problem. Perhaps the park's access difficulty has challenged not only me but also the locals.
</p>


<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/shenzhen_cultural_center.jpg' alt='Shenzhen Cultural Center' />
  <br />
  Shenzhen Cultural Center
</div>
</div>

<p>I went out to see the soaring architecture of the Shenzhen Cultural Center on the other side of the park. I figure the building is too far for me to walk to. So my goal is to find a vintage point to take a good picture. This require a long walk through some confusing pathway in an empty park. But the walk just keep getting longer without going anywhere. Many times I have considered to give up my pursuit. This will be a slap in my face since I pride myself in my wayfinding skill. When I finally reached the edge of the park, I found a boulevard and the cultural center in a distant. Nice architecture. But there seems no way for me to continue the walk. It is not even an inviting landscape for a pedestrian. I just took my picture and then walked back.
</p>

<p>By now I have spent a fair amount of time walking under the sun. I need to return to civilization to grab my lunch. But there are more long trek before I have finally reached a shopping center and its food court. I finally got a sense of Shenzhen's cityscape. It is a new city done in grand scale, wide boulevards, monument buildings and huge parks. But it is not a livable city that I enjoy.
</p>


<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/shenzhen_sheraton.jpg' alt='Las Vegaseque Sheraton Hotel' />
  <br />
  Las Vegaseque Sheraton Hotel
</div>
</div>

<p>You can tell I was getting cranky. The lousy Chinese fast food I have had did not help either. I rushed back to the Hong Kong side to end this short trip.
</p>

]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Wed, 30 Jun 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>Pedestrians v.s. Cars - Pedestrians Win!</title>
   <guid isPermaLink="false">2010/2010-06-29_pedestrians_vs_cars_pedestrians_win</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-06-29_pedestrians_vs_cars_pedestrians_win.html</link>
   <description><![CDATA[
<p>Causeway Bay is a major shopping district in Hong Kong. Gazillion number of people come by Causeway Bay every day. Over the year, one street after another have been converted into pedestrian use. Instead of squeezing into overcrowded sidewalk, more space are make available for pedestrian. This makes walking in Causeway Bay a much better experience.</p>


<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/causeway_bay_pedestrian_street1.jpg' alt='Causeway Bay Pedestrian Street' />
</div>
</div>


<p>Hennessy Road is the major thoroughfare in Causeway Bay. The surrounding streets are often narrow and labyrinth like. These streets were once only backstreets behind major department stores. Today they are destinations themselves with many boutiques stores and restaurants. These side streets are lousy for moving traffic but terrific for walking and shopping. It is a superb idea to close them for cars and open them for pedestrians.
</p>


<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/causeway_bay_pedestrian_street2.jpg' alt='Causeway Bay Pedestrian Street' />
</div>
</div>


<p>Some streets have permanently converted into pedestrian plaza. They are nicely paved and raised to level with the sidewalk. But in other area, it is not obvious what has been done to restrict vehicle access. In the picture above, the only control device seems to be the sign that says "Access Only". In the morning the streets are lined with delivery truck, those access is expressly allowed. Still access restriction is working quite well with relatively few vehicles coming in. The taxi in the picture below is one of those.
</p>


<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/causeway_bay_pedestrian_street3.jpg' alt='Causeway Bay Pedestrian Street' />
</div>
</div>


<p>With few physical marking, how do I recognize this as a newly created pedestrian area? I think the pedestrians themselves make it a pedestrian street. When sufficient number of people come off the sidewalk and go into the street, it makes driving through difficult. Cars become intruder there. These pictures are taken in the morning when actions have barely started. I'm sure when people are coming out in full force in the evening it will become impassable for cars.
</p>



]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Tue, 29 Jun 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>Plastic Bag Tax in Hong Kong</title>
   <guid isPermaLink="false">2010/2010-06-28_plastic_bag_tax_in_hong_kong</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-06-28_plastic_bag_tax_in_hong_kong.html</link>
   <description><![CDATA[
<p>After many years of debate, Hong Kong has finally decided to impose a 50 cents (USD 0.06) tax on the use of disposable plastic bag in supermarkets. There have been many efforts to convince people to reduce plastic bag use voluntarily. But mostly the shops hand out bags freely and the result is very limited.
</p>

<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/hong_kong_plastic_bag_charge.jpg' alt='50 cents per bag in Hong Kong' />
</div>
</div>

<p>
I was shopping in a Causeway Bay supermarket in the basement of a Japanese department store. To see how effective this law is, I've spent a few minutes to observe the shoppers coming out from the cash register. The ratio of people using their own reusable bag vs. disposable plastic bag is roughly half and half. I was hoping even more people would bring their own bag. But compare to the baseline figure a few years ago where reusable bag usage is almost 0, this is certainly a big improvement.
</p>

<p>See also my eariler entry about <a href=" http://tungwaiyip.info/blog/2010/06/02/california_plastic_bag_ban">proposed plastic bag ban in California</a>.</p>


]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Mon, 28 Jun 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>Remember this moment - with Tatchee in Hong Kong</title>
   <guid isPermaLink="false">2010/2010-06-25_remember_the_moment</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-06-25_remember_the_moment.html</link>
   <description><![CDATA[
<p>Remember this moment.</p>

<p>It is a quite summer afternoon in Hong Kong. It has been raining since the morning. I sit in my room. My bed is at the corner of the small room. Three years after my parents moved into this new house, we still haven't taken the Styrofoam cover off the bed's headboard. My mom bought the bed for me in case I return for a stay.</p>

<p>Tatchee is sleeping in the couch. I make him sleep on my leg at first. A pleasant surprise for me that he did fall asleep. The temperature is not too high. But he has sweat all over. My dad is laying on his bed reading before his regular afternoon nap.</p>

<p>Last night Tatchee sleep with me in the bed. He fall asleep quickly. At 6:30am he has woke up. I went down to the street to bought him some bread. He didn't really want the bread so much. We played toy robots. He keep asking me to play robot with him all day. We probably played a few hours total in several stretches. It is not such a fun game for me but I like it that we played together. He dropped the ‘Shark’ tank toy on the floor and destroyed it. It was actually a toy I had from my boyhood. It was a gift that my neighbor bought me from a trip in Japan. I find it sweet that he has taken interest in a toy left over from my boyhood. It is sad that it was broken so easily.</p>

<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/broken_jaguar_vulcan.jpg' alt='Broken Jaguar Vulcan' />
</div>
</div>

<p>It is a rainy day, so I can't take him to other activities outside.</p>

<p>My father cooked. Tatchee ate both meal fairly well.</p>

<p>Yesterday we went to swimming pool. I have promised to take him there. He played water gun and seesaw and water slide. He asked me to go under the shallow water with my goggles. He has fun. It was fairly windy that day and it was surprising cool in pool.</p>

<p>And then we take shower. For the very first time, I shampoo Tatchee under a shower. He used to protest when I shower him over his head. But his time he covered his eye with his hands and manage just fine. An excellent first time.</p>

<p>After we left the pool, we go to a bench so that he ate the sponge cake his mom gave him. And then we went to visit my mom's shrine. We climbed 10 flights of stairs to get to her shrine. I found it without too much effort. Tatchee recognize her pictures on the stone. We say hi to her.</p>

<p>I remember this moment, a summer afternoon at home in Hong Kong.</p>


]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Fri, 25 Jun 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>Decalogue I</title>
   <guid isPermaLink="false">2010/2010-06-14_decalogue_i</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-06-14_decalogue_i.html</link>
   <description><![CDATA[
<p>How long ago was it when I went to the marathon screening of Krzysztof Kieslowski's Decalogue, the entire ten episodes shown in one full day? It must be more than 15 years ago. Kieslowski's films have a such important place in my memory, it is hard to imagine he has left more than 10 years ago.
</p>

<p>This time I have as much time as I need to review each episodes on DVDs. The Decalogue One, <i>"I am the Lord thy God; thou shalt have no other gods before me"</i> is a about a tragic accident. Against all the computer calculation and precaution before going on ice skating on the frozen lake, accident has befallen on the young Paweł. Daddy returns home to stare at the green glow of the screen of his trusted computer. Just yesterday it made the assurance on the ice strength. Now it displays a single message - "I am ready _" with a blinking cursor. The picture remains there silently. It is some of the most contemplative moment in the cinema.
</p>

<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/decalogue1.jpg' alt='Decalogue I' />
</div>
</div>

<p>I don't remember how I feel when I saw this the first time. The message is simple enough. It questions the primacy of science and structure in modern society and to reflect on the diminishing role of religion and spirituality.
</p>

<p>Today I think I have resolved such conflict. It is a false dichotomy between science and religion. To me science is spiritual. The story implies a kind of scientific determinism. I think it is old school. Of course old school probably still describes the majority of people, both religious and non-religious. And also we have to take into account of Kieslowski's background working in the communist Poland in the 80s, where determinism is really the rule of the society and has far more relevance for him.
</p>

<p>The flaw of Decalogue One is some may see it as an apology for scientists. Many people may simply conclude scientists are arrogant and ultimately hurt people. If so they are too affected by the accident. Kieslowski is a master to induce us into reflection of a moment. But we must not lose the bigger context to a single moment. Can religion or traditional knowledge make a better guideline regarding safety compare to science overall? I doubt it.</p>

<p>And this is only old school science. The "new" science of complexity sees the world as fundamentally nondeterministic. Many events are unpredictable. Accidents do happens. But this does not mean scientific prediction are not useful. They are useful in plenty of ways. The problem is those people who expect 100% certainty are not realistic of their expectation.
</p>

<p>In the middle of the film the father was giving a lecture on language. Unlike other old school point of view, this lecture on the relationship of language and intelligence resonates deeply to me. He laments that computers, a machine that operates on 0 and 1, can somehow displays awareness. He was talking about <b>emergence</b>! It strikes me that human, an organism makes up of simple molecules and a lot of H<sub>2</sub>O can display awareness. So a man made machine, despite its seeming simple logic structure, can conceivably display a consciousness on a high level someday by the similar principle.
</p>

<p>I don't have a conflict between science and spirituality. Science is my new religion. This is of course the topic of another 100 blog posts.
</p>

]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Mon, 14 Jun 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>HTC EVO Battery Gets Better</title>
   <guid isPermaLink="false">2010/2010-06-11_htc_evo_battery_gets_better</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-06-11_htc_evo_battery_gets_better.html</link>
   <description><![CDATA[
<p>Last time I recorded my <a href="http://tungwaiyip.info/blog/2010/06/05/how_i_keep_the_htc_evo_alive_for_2d_15h_41m">HTC EVO battery lasted over 2 days</a>. It has gotten better. This time it has cleared 3 days of light use.</p>

<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/HTC_EVO_battery2.jpg' alt='HTC EVO battery use' />
</div>
</div>

<p>For me its battery performance is on-par with other smart phones.</p>





]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Fri, 11 Jun 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>How I Keep The HTC EVO Alive For 2d 15h 41m!</title>
   <guid isPermaLink="false">2010/2010-06-05_how_i_keep_the_htc_evo_alive_for_2d_15h_41m</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-06-05_how_i_keep_the_htc_evo_alive_for_2d_15h_41m.html</link>
   <description><![CDATA[
<p>By putting it in airplane mode! Don't laugh. Please read on.
</p>

<p>The Sprint HTC EVO is the latest Android handset coming into the market. It is a first phone that supports 4G WiMax (though not yet available here in San Francisco). And it boasts a massive 4.3" display and 8MP video camera. But all the report coming in during its first week of debut confirm one thing, its battery life sucks. Some reports complaint the battery won't even last a full day of use.</p>

<p>The verdict aren't universal though. Some people got considerably more battery life than the others. How much people actually do with the phone is of course one major factor. But it also dawn on me that the battery life isn't determine by the phone alone, the network signal strength also play a large role. For those lucky folks who receives a strong signal, the phone exert relative little power to stay connected. Conversely when the network signal is weak, the phone has to increase the power of wireless signal to remain connected, thus draining the battery faster.
</p>

<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/HTC_EVO_battery.jpg' alt='HTC EVO battery use' />
</div>
</div>

<p>The signal in my bedroom has relatively weak signal. It bounces between 2-4 bars out of six. So I turn on the airplane mode when I go to sleep. Nobody want to receive a call while they are sleeping, don't they? I'm still using it as an alarm clock to wake me up in the morning, when I'd turn it back on to receive calls. In 3 nights it saved 24 hours of battery use for unneeded cell connection.
</p>

<p>I wasn't testing how long the phone last while idling. I was using it every day. But I use it judiciously with the battery conservation in mind. Here are some of the things I have done:
</p>

<pre>
4G off
WiFi off (except of short use)
GPS off (except of short use)
Bluetooth off

Phone calls a few minutes a day
Some web browsing
As a WiFi hotspot (several minutes a day)
A lot of music playing
Background syncing (e.g. Google Calendar)
10 minutes of GPS tracking
</pre>

<p>I think EVO's battery is adequate for me. It is worst than my iPhone, which routinely gets 3 days of life even after nearly two years of use. But EVO's battery is sufficient to me. </p>

<p>I want to mention that I've done all these battery conservation trick for my iPhone initially, including putting it into airplane mode during the night. Initially my iPhone 3G sometimes didn't last a day if I didn't use it carefully. After multiple OS update, its battery life has actually gotten considerably better. I hope EVO will also improve as newer version of Android comes out to make more efficient use of the battery.
</p>

<p><i>(Update: <a href="http://tungwaiyip.info/blog/2010/06/11/htc_evo_battery_gets_better">the battery has lasted 3 days</a> in my later test)</i>
</p>





]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Sat, 05 Jun 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>California Plastic Bag Ban</title>
   <guid isPermaLink="false">2010/2010-06-02_california_plastic_bag_ban</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-06-02_california_plastic_bag_ban.html</link>
   <description><![CDATA[
<p>I'm delighted to hear that the California legislature is consider to <a href="http://www.sfgate.com/cgi-bin/article.cgi?f=/c/a/2010/06/02/MN6N1DO77G.DTL&tsp=1">ban the use of plastic and some paper bags</a> from retails. If the law passes, we will be joining other nations like Ireland and China in curbing irresponsible use of disposables and reduce the pollution to the environment.</p>

<p>Three years ago, over the objection of California Grocers Association, <a href="http://articles.sfgate.com/2007-03-28/news/17235798_1_compostable-bags-plastic-bags-california-grocers-association">San Francisco was the first city in California to ban the use of plastic bags</a> in large stores. Like many progressive ideas sprout from this city, it seems too radical to some people at the time. Business groups opposed and loud mouthed critics spare no effort to ridicule San Francisco. But time and again, what appear as crazy ideas at the beginning get wide acceptance eventually. Remember things like recycling and gay right. Before they get wide acceptance today, they were fiercely opposed and ridiculed at the beginning. After San Francisco, a few cities like Oakland quickly joined to ban plastic bag. Finally it spreads to the entire state. This time the California Grocers Association has turned around to support the registration. It only take them 3 years!</p>

<p>The final opponent to this bill is none other than the plastic industry. I want to take aim at their fallacious claim this will result in higher prices to consumers. The most important point is the cost of disposable bags will be trivial compare to cost of goods. That's why retails are willing to hand out bags freely in the first place. But if the ban of plastic bag has any effect on price at all, it should lower it. 'Free' plastic bags are after all, not free. Their cost are just part of the retailer's business cost and will be reflected in the price.</p>

<p>If I'm plastic bag manufacturers, I would consider switching gear to other high value product like tote bags, which can sell for $10 or more. Why be the bad guy producing millions of plastic bags at low margin and pollute the environment? Stop making product for pennies and start making high margin product! It is good for your bottom line and it is good for your karma.
</p>

]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Wed, 02 Jun 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>Why Smart People Make Big Money Mistakes</title>
   <guid isPermaLink="false">2010/2010-05-27_why_smart_people_make_big_money_mistakes</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-05-27_why_smart_people_make_big_money_mistakes.html</link>
   <description><![CDATA[
<p>
I have just finished a fascinating book, <a href="http://www.google.com/search?ie=UTF-8&q=isbn+9781439163368">Why Smart People Make Big Money Mistakes</a> by Gary Belsky and Thomas Gilovich. Traditional economics considers people as rational being, acting to optimize one's own welfare. In practice, few people really acting rationally all the time. Even well informed people have found to make many faulted financial decisions. Behavioral economics incorporates psychology and cognitive factor into consideration. It have found great insight into people decision making process.
</p>

<p>Below are simply my notes taken from the book.</p>

<p>Ch.1 <b>Mental Accounting</b>, Richard Thaler. <b>Statistical Regression</b>, Sir Francis Galton, 1911 (tendency to fall back into statistical mean).
</p>

<p>Ch.2 <b>Prospect Theory</b>, Daniel Kahneman, Amos Tversky, 1979. (Issue framing, e.g. loss aversion, sunk cost fallacy).
</p>

<p>Ch.3 The Devil That You Know</p>

<p>Decision Paralysis - tendencies to avoid or delay action, particularly due to the fear of regret and a preference for the familiar.

<ul>
<li><b>Maximizer/Satisfier</b> - Herbert Simon, 1950s.</li>

<li><b>Trade off contrast</b> - choices are enhanced or hindered by the tradeoff between options, even for options we wouldn't choose anyway, Tversky, Simonson.</li>

<li><b>Extremeness aversion</b> - people are more likely to choose an option if it is an intermediate choice within a group, Tversky, Simonson. (so it can be manipulated by introducing extreme choice).</li>

<li><b>Status quo basis</b>, <b>endowment effect</b> - preference for holding on what you have.</li>

<li><b>Regret aversion</b> - avoid the pain of regret and the responsibility for negative outcomes.</li>

</ul>

<p>Counter Measures
<ul>
<li>Take opportunity cost into account</li>
<li>Mark Twain's saying, "Twenty Years from now you will be more disappointed by the things you didn't do than by the ones you did do."</li>
</ul>
</p>


<p>Ch.4 Number Numbness

<ul>
<li><b>Neglecting the base rate</b> - tendency to disregard or discount overall odds, Kahneman, Tversky.</li>
</ul>
</p>

<p>Ch.5 Dropping Anchor
<ul>
<li><b>Anchoring</b> - clinging to a fact or figure or idea that may or may not have any real relevance to your judgment or decision.</li>

<li><b>Confirmation bias/Preferential bias</b> - once people developed bias, they tend to view new information in such a way that it supports those preferences (Edward Russo).
</li>
</ul>

</p>

<p>Ch.6 The Ego Trap</p>

<p>The tendency to attribute success to your ability but to attribute failure to other causes.
<ul>
<li>Heads I win, tails it's chance, Eileen Langer, 1975</li>
<li>"Expert" predicition, Tetlock</li>
<li>"Hindsight bias", Baruch Fischhoff</li>
</ul>
</p>

]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Thu, 27 May 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>My New Desktop Background</title>
   <guid isPermaLink="false">2010/2010-05-26_my_new_desktop_backgound</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-05-26_my_new_desktop_backgound.html</link>
   <description><![CDATA[
<p>This is the picture I've used as my new desktop background. What is that? I think this is just some random picture my 4 year old son has taken. You know, he has learned to aim a camera to something, press the shutter button and got his own pictures. He makes outrageous mistakes by photographers' standard. A lot of times the lens was obscured by his finger, the picture was blurry, or he has framed on some unobvious objects. But sometimes his pictures also have certain abstract, artistic quality, certain intricacy of light, something totally original that you will never know how to make. So instead of just deleting his pictures, I have kept some of them.</p>

<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/my_desktop_background.jpg' alt='Abstract Desktop Background' />
</div>
</div>

<p>When I was flipping through my picture library to select a desktop background, one of his come out fittingly! I used to use pictures of beautiful landscape or family portrait as a background. What a mistake! The subject, the detail and the contrast are really distracting. Desktop is a place for holding clutters and a place for work. If you want to see beautiful picture, you should run a slide show. Turn out this out of focus picture of some place in my home works wonderfully. It stays in the background as a background image should. It provides good contrast to the icons over it. It has more visual interest than a plain solid color background. And viola, I've a totally unique picture nobody else has!
</p>

]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Wed, 26 May 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>Droid v.s. iPhone - My First Impression</title>
   <guid isPermaLink="false">2010/2010-05-19_droid_vs_iphone_my_first_impression</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-05-19_droid_vs_iphone_my_first_impression.html</link>
   <description><![CDATA[
<p>I have received Motorola Droid phone as a free gift courtesy from Google. My first question, do I really want an Android phone? I'm an iPhone user of 1.5 year. My service contract has not even ended. But since it is free I'll just give it a try. This is a report of my impression after using it for a few weeks.</p>

<p>The first thing that delights me is Droid has a physical keyboard! The onscreen keyboard is one of my biggest issue with iPhone. Despite iPhone fans' claim, the inaccuracy of onscreen keyboard bothers me. Unfortunately, Droid's keyboard quickly disappoints. The keys are flat. Its tactile feeling is so so. The keys are arranged as a rectangular grid rather than staggered. As much as I dislike onscreen keyboards, I can enter keys with a light touch. With this keyboard I have to push hard each time. My thumbs get sore quickly.</p>

<p>There are more serious problems though. I want to kill the designer who line the number keys on the top row. It is a real pain to type any long number like a phone number. Holding down the ALT key with the left thumb and reaching for the number key with the right thumb while trying to hold the handset steady is such a struggle. Yet this can be fixed simply by having a different layout. Arrange the keys in a numeric keypad pattern as in the diagram will do. You can easily use the left thumb to hold down the ALT key and type any numbers with the right thumb all sitting close together.</p>

<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/droid_numeric_key.jpg' alt='Droid Numeric Key Layout' />
</div>
</div>


<p>Another problem is the alignment of the keyboard. Due to used space on the right, the Droid keyboard is significantly off centered toward the left. On a normal keyboard, the G and H keys are at about the center. On Droid, because the H key is so far to the left, it makes it much harder to reach it using the right thumb. As such Droid has a QWERTY keyboard that does not really feel like a QWERTY keyboard. What a shame! To this day my most favorite phone keyboard is still the first generation Sidekick. The large and well positioned keyboard makes it a real note taking machine!</p>

<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/droid_vs_sidekick.jpg' alt='Droid v.s. Sidekick keyboard' />
</div>
</div>


<p>If the keyboard does not work as well as it should, the direction pad is still great. For navigation, the direction pad delivers much better precision compares to  touch screen. I like to scroll using it rather than the imprecise, trial and error flicking gesture. Even better is its preciseness for moving the cursor inside a text for editing. With iPhone, it is super frustrating to try to position the cursor in any different location. So much that I simply give up correcting typing error or do much editing. With Droid I am writing this entire post using the phone, editing out every single error as I see it. Still there is a problem with Droid's direction pad. The key is hidden under the screen, making it unavailable when the lid is closed.</p>

<p>The 5MP camera is a big improvement over my iPhone's. The quality is approaching a basic digital camera. But most importantly, it has a macro lens that's pretty good at close up. This allows me to do what I like to do for a long time, to draw sketches on paper or whiteboard, then pull out a camera, take a picture and send it to my computer to be incorporated into a document or email. The keyboard sketches that I used in this post is the way I like to do. The important point here is not to produce the best quality illustration, which takes time and resources. It is that the process should be easy and casual. Just like drawing with pencil and paper. Droid is the first tool that make this feasible.</p>

<p>One of the key component that makes it possible is Gmail. This is how I transfer the pictures from the phone to my computer. Much to Google's credit, integration with Gmail is super smooth. The first time you setup the phone, it ask for your Google account information. Assuming you have a Google account, your are done. Gmail works right away! Google calendar also works! And you don't need to do any manual tethered syncing using iTunes!</p>

<p>Finally I want to comment on Android's UI Aesthetic. After using iPhone for a while, I find Android rather verbose. On iPhone the home screen is populated with big application icons. I can find application by picking from the pictures. With Android it is difficult to identify the application from their icons. They are about 30% smaller and their design seems not very distinguishable. Instead I have to pick the application by reading the text under it. Secondly iPhone UI relies more on icon and direct manipulation. It keeps the use of text to a minimal. On Android I often see long phrases, or even a complete sentences, for describing the action. Contrast their setup screen for the difference in style.</p>

<div style='text-align: center'><!-- IE hack -->
<div style='margin: 2ex auto 2ex auto; '>
  <img src='/2010/img/droid_vs_iphone_setup_screen.jpg' alt='Setup screen Droid v.s. iPhone' />
</div>
</div>

<p>I suspect my son won't like my Android phone as much as the iPhone. Well he is only 4. So why does it matters? The things is he start to play with my iPhone before he turns 3, and has become quite good in applications like the camera or the photo gallery. All these he mostly learn on his own with few instruction from me (indeed I actively discourage him from messing with my phone.) I think this is a testimony that the iPhone UI is a really phenomenal success. It sets a high bar for others to beat.</p>

]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Wed, 19 May 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>Python CSV reader is much faster than pickle</title>
   <guid isPermaLink="false">2010/2010-05-12_python_csv_reader_is_much_faster_than_pickle</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-05-12_python_csv_reader_is_much_faster_than_pickle.html</link>
   <description><![CDATA[
<p>If you are considering to serialize a large amount of data to the disk, performance may become a concern to you. Python provides a serialization tool in the pickle module. There is also an optimized version called the cPickle. But how do they perform?
</p>

<p>The data of concern to me is tabular data. In order to do a bake off, I have generated 50,000 records of sample data. The CSV representation is shown below:
</p>

<pre>
seq, name, address, city, age, birthday
1000,John M. Doe,2147 Main St.,Middle Town 14,47,1985-05-15
1001,John N. Doe,2148 Main St.,Middle Town 15,48,1985-05-16
1002,John O. Doe,2149 Main St.,Middle Town 16,49,1985-05-17
1003,John P. Doe,2150 Main St.,Middle Town 17,50,1985-05-18
1004,John Q. Doe,2151 Main St.,Middle Town 18,51,1985-05-19
1005,John R. Doe,2152 Main St.,Middle Town 19,52,1985-05-20
1006,John S. Doe,2153 Main St.,Middle Town 20,53,1985-05-21
1007,John T. Doe,211 Main St.,Middle Town 21,1,1985-05-22
...
</pre>

<p>Naturally, CSV is a contender for storing tabular data. (Indeed the data source I'm working with is in CSV format.) The two pickle modules produce identical data output. In addition, Python 2.6 also provides a JSON module that do the similar task as pickle but outputs a standard text based format. I included it in the comparison below.
</p>

<p>First observation, CSV output the most compact data at 3MB. Pickle output is 40% larger at 4.2MB. JSON is somewhere in between. The speed? CSV is the winner among them all.
</p>

<br />

<div>
<table border='1' cellspacing='0' cellpadding='2'>
<tr> <td>Method</td> <td>Load Time (ms)</td> <td>File size (MB)</td> </tr>
<tr> <td>CSV     </td> <td>  188</td> <td>3  </td> </tr>
<tr> <td>CSV int </td> <td>  289</td> <td>3  </td> </tr>
<tr> <td>cPickle </td> <td>  692</td> <td>4.2</td> </tr>
<tr> <td>pickle  </td> <td>1,815</td> <td>4.2</td> </tr>
<tr> <td>JSON    </td> <td>4,975</td> <td>3.9</td> </tr>
</table>
</div>

<p>Note that CSV reader create data items as string. In the sample data, two out of the six columns are integer fields. In order to do an apple-to-apple comparison I have another test that do integer conversion after loading such that the data loaded is identical to pickle's. This impacted the performance somewhat. But it is still more than twice as fast as the faster cPickle module. The standard library's JSON's performance trailing far behind, making it unsuitable for anything performance intensive. FYI, unlike the other modules, JSON's output is in unicode.
</p>

<p>The test is done by Python 2.6 on Windows XP machine with 2.33GHz Core2 CPU (<a href="/2010/pickle_test.py">Download source code</a>).
</p>

<br />

]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Wed, 12 May 2010 07:00 GMT</pubDate>
</item>
<item>
   <title>The Day When Machines Rule The World</title>
   <guid isPermaLink="false">2010/2010-05-07_the_day_when_machines_rule_the_world</guid>
   <link>http://tungwaiyip.info/blog/2010/2010-05-07_the_day_when_machines_rule_the_world.html</link>
   <description><![CDATA[
<p>Yesterday the U.S. stock market experienced a sudden and volatile fluctuation. Dow Jones index has briefly dropped by 10% during intraday trading. The main culprit seems not to be economic issue but suspect to be a glitch in trading. Apparently one trader has entered an exceptionally large trade by mistake, which set off all the automatic trading program to sell-off. There goes the market value.
</p>

<p>Watching this episode I see a picture emerging. This is the day when machines begin to rule the world. For all the vigilance put in place after the computer induced 1987 market crash, we are still, or perhaps even more vulnerable due to more reliance on computers.
</p>

<p>The conflict of man against machine seems like a sci-fi plot. But I think it is more realistic than most people think. The problem is we are looking for an anthropomorphous entity like HAL, an supercomputer that knows it all, have immense analytic power, and the most frightening part, it has a mind of its own. As far as I know I don't see anything like this on the horizon.</p>

<p>Instead there are countless software agents roaming the net, collecting information, building database, distributing information and in some case taking active roles like trading stock. This global computer network has developed immensely in the past 2 decades, impacting every aspect of our society. Mostly it makes our economy more efficient and keeping us better informed. But does the system also enslave us in some way? Are human truly in control of our destiny. Or are we at the mercy of the system?
</p>

<p>I am imagining how the next computer glitch would look like. Think Google Calendar. One day it may suddenly 'recommend' a political rally event to all users, those logic that even its creator cannot explain. And our history may have changed as a result.
</p>

]]></description>
   <category domain="http://tungwaiyip.info/blog">/2010</category>
   <pubDate>Fri, 07 May 2010 07:00 GMT</pubDate>
</item>
</channel>
</rss>
