tungwaiyip.info

 

home

about me

links

my software

Media

Yucatán Photos

St Lucia Photos

Photo Album

Videos

Blog

< February 2010 >
SuMoTuWeThFrSa
  1 2 3 4 5 6
7 8 910111213
14151617181920
21222324252627
28      

past articles »

Click for San Francisco, California Forecast

San Francisco, USA

 

Visualization Using Variable Width Bar Chart

I was plotting a chart to visualize various development project in my area. The primary concern is in development density. But the project footprint itself is also a factor. We want to focus on big project that matters. We also want to identify outliers that has very high or very low density, but otherwise has small overall size and less relevance.

My solution is to use a variable with bar chart below. The height of each bar represents the density. The width represents the lot size. The area of each rectangle bar reflects the total number of units. The full article is posted in Potrero Boosters Neighborhood Association's website.

potrero condo density

I thought everything that worth inventing has been invented. So I was frustrated that I cannot find a tool to generate this chart. Nothing in Excel (that I know) can generate a chart like this. I end up turning to matplotlib. But even matplotlib does not seem to have a function that support this directly. Fortunately a small twist to its histogram function does the job for me. See my (unpolished) source code here. In any case working with matplotlib is fun and the quality of the chart is excellent.

2010.02.26 [, ] - comments (0)

 

Refrigerator Madness solution (Facebook programming puzzle)

Refrigerator Madness is the second Facebook programming puzzle I have tried. The problem description is complicated. I won't try to repeat it here but to suggest you to refer to the original facebook page.

To solve this problem it is necessary to see through the smokescreen. Instead of thinking how much Red Bull a Facebook engineer likes to drink, it is easier to map it to a problem known as Two-Sided Matching. A model with intuitive meaning is a marriage matchup between a group of man and woman. Each man has his list of preferred woman and each woman has her list of preferred man. The marriage is considered stable if there are no two people of opposite sex who were not married to each other but would both prefer to be.

For the Refrigerator Madness problem just map the engineer from the upper 50th percentile to "man" and lower 50th percentile to "woman" (or vice versa). The matching condition is equivalent to the stable marriage criteria.

At this point the problem can be solved by applying the Gale-Shapley algorithm. Write the code and it's done!

2010.02.22 [] - comments (5)

 

smallworld solution (Facebook programming puzzle)

Facebook has published a number of programming puzzles to challenge software developers. Their problems are not trivial at all. This is my attempt on "Snack" level problem It's A Small World. Even this one take me sometimes to solve.

The idea is that there are n points on a 2-dimensional plane. For every point, we have to find the 3 nearest neighbors. The naive solution simply match all possible pairs, resulting in O(n2) complexity. The problem requires us to find a better solution than O(n2).

My idea is to divide the plane into a regular grid like below. For example, to find the neighbor of point A, we can focus on cell 2 in the center top and pretty much ignore the points in cell 9 in the lower right. This works very well if the points are randomly distributed. But if many points are clustered together like cell 9, it will work less well. We can recursively partition it into smaller region. But the basic plan should be suffice for this puzzle. The subdivision is a very simple O(n) process.

grid

To search for the nearest neighbor, we start from points from the same cell. If this doesn't find the three nearest neighbors we extend into the neighboring cells. The pseudo code is shown below:

  result = None

  for step in 0...n

    cells = find cells "step" away from the source
    min_distance = minimum distance from source to the boundary of the cells

    for all point in cells
        insert distance(source, point) into result

    result = 3 closest points in result

    if there exists 3 points in result those distance < min_distance
        return result

  end for

Of course I'm not the first one to consider these algorithm. Wikipedia has some information on the Nearest neighbor search problem. My solution code is available here. (2010-02-21 Facebook's puzzle server is down. So the solution has not been validated.)

I have decided to put the algorithm into good use. I used it to generate a map of all sizable cities in the world and their nearest neighbors. With 20,000 cities a naive algorithm will need 400 million pairing. Using this algorithm only 10 million pairing are need. It is far from optimal, but good enough to handle Facebook's problem. Also I am curious to use it to find the loneliest city in the world, that is, a city those nearest neighbor is the furthest away. Check the map to find out which city is the loneliest city in the world!

2010.02.21 [] - comments (3)

 

How Google Screw Up in China, the Missing Story

Last month the IT world is jolted by the news of a security breach of Google's system by Chinese hackers and the subsequence response by Google threatening to pull out their China operation altogether. Many in the west see this as a courageous resistance to China's Internet censorship and a righteous response to the assault on some human right activists. Other observers noted that Google's market share in China is trailing far behind the local competitor, that they may using this incident to give themselves a graceful excuse to exit.

All of them could have learned something from anthropologist Tricia Wang's insightful observation of Google's uses or non-use in China. Tricia is a research scholar working in China to study how youths and migrants are using ICT to manage their inter-personal communication networks. She come up with her observation from the angle of grassroot youngsters.

Among her observations are

  • Google is mostly irrelevant to Chinese users. While elite, educated Chinese depend on Google as much as others do, young people has a very different usage pattern. They mostly use Internet with IM or mobile devices to connect to their friends. They have never found Google to be useful.
  • Google has a huge branding issue in China. Most Chinese cannot spell the word 'Google'! I was amused to find that Google is known by its colloquial name GouGou (狗狗doggy) more than its official name Gu-Ge (谷歌). Here in the west, especially within the IT industry, Google's brand name stands for leadership in innovation and intelligent services. There in the back street of China, Google's name is associated with the lowly doggy. What a satire!

Tricia has an excellent piece of analysis that should be on most reader's radar screen.

2010.02.11 [] - comments (0)

 

Your Second Life Is Better Than Your First Life?

Your walk in a cafe. You see everyone is working alone with their laptop. Nobody is talking to each other. Even the most ardent Internet junkie would admit they should have spent more time personally with other people rather than glue to the computer screen all day long. These cafe owner even try to setup rules asking patrons to log off and talk.

No more laptop?

These moves are no doubt well intentioned. It will probably inspire many supporters. But why is so many people stick to their computer in the first place? It would be easy if we can determine that too much Internet is for sure a bad behavior, like watching too much TV. But what if it is true, that your second life is actually better than your first life?

2010.02.06 [] - comments (0)

 

past articles »

 

BBC News

 

Spending cuts 'to hit north harder' (09 Sep 2010)

 

Obama condemns Koran burning plan (09 Sep 2010)

 

MPs back new phone hacking probe (09 Sep 2010)

 

Defence firm BAE cuts 1,000 jobs (09 Sep 2010)

 

Chote set to head Budget office (09 Sep 2010)

 

Graduates 'will have to pay more' (09 Sep 2010)

 

UK interest rates remain at 0.5% (09 Sep 2010)

 

British hostage freed in Pakistan (09 Sep 2010)

 

Cameron tribute to 'amazing dad' (09 Sep 2010)

 

Planes nearly collide over London (09 Sep 2010)

more »

 

Slashdot News for nerds, stuff that matters

 

DHS CyberSecurity Misses 1085 Holes On Own Network (2010-09-09T13:24:00Z)

 

Rackspace Shuts Down Quran-Burning Church's Sites (2010-09-09T12:47:00Z)

 

IOS 4.1 Jailbroken Already (2010-09-09T11:57:00Z)

 

Scientists Cut Greenland Ice Loss Estimate By Half (2010-09-09T08:57:00Z)

 

DARPA Wants Extreme Wireless Interference Buster (2010-09-09T06:49:00Z)

 

Film Industry Hires Cyber Hitmen To Take Down Pirates (2010-09-09T04:28:00Z)

 

The Real "Stuff White People Like" (2010-09-09T03:27:00Z)

 

Biometric IDs For All India's Citizens (2010-09-09T02:09:00Z)

more »

 

TechPsychic Tech Rumors and Invented News

 

TechPsychic: AT&T: more money, says it's disruptive in funding from. (08 May 2010)

 

TechPsychic: I know that Apple is close to Apple Dominates, Hires ex-Googler - Yes, Android phones. (08 May 2010)

 

TechPsychic: AT&T says: Facebook Connect. (08 May 2010)

 

TechPsychic: Google's Nexus One of Google Chrome Release Adds Support subscriptions accounted for Amazon: Apple. (08 May 2010)

 

TechPsychic: Another stat: Twitter's Design of this is giving rise of BlackBerry Foursquare Map App store end. (07 May 2010)

 

TechPsychic: Like educational sales Up around Apple iPad makes money Plan costs half an Apple. (07 May 2010)

 

TechPsychic: Instead added extensions, social Networks than double, everyone jumps in Silicon Valley? (07 May 2010)

 

TechPsychic: So why iTunes App lets Social Networks Verizon Wireless Internet. (07 May 2010)

more »

 

SF Gate

 

Oakland's Koreatown roiled by parolee center (2010-09-09T13:13:51UTC)

 

BART connector to Oakland airport inches ahead (2010-09-09T12:40:24UTC)

 

Dems urge Brown to step up fundraising effort (2010-09-09T07:07:44UTC)

 

High court won't order state to defend Prop. 8 (2010-09-09T07:07:17UTC)

 

Regret, apology not part of BP's oil spill report (2010-09-09T09:41:49UTC)

 

Clinton, Gates denounce planned Quran burning (2010-09-08T23:18:40UTC)

 

Official: 2nd killed in flooding swamping Texas (2010-09-08T20:32:22UTC)

 

Muni riders welcome restoration of service cuts (2010-09-08T20:54:56UTC)

 

Fire at pallet company lights up Buffalo, NY, sky (2010-09-09T13:37:39UTC)

 

Stocks continue rally after drop in jobless claims (2010-09-09T13:36:39UTC)

 

Apple to publish guidelines for app approval (2010-09-09T13:34:03UTC)

 

Burger King buyer names future CEO (2010-09-09T13:33:34UTC)

 

Trade deficit narrows to .8 billion in July (2010-09-09T13:33:30UTC)

 

Official condemns German lawmaker comment on WWII (2010-09-09T13:33:21UTC)

more »

 

Asia Times Online

 

ASIA HAND : Exalted Aquino has far to fall (9 Sep 2010)

 

Hariri exonerates Syria over father's murder (9 Sep 2010)

 

There's another side to Obama's COIN (9 Sep 2010)

 

Taliban winning hearts - and more (9 Sep 2010)

 

Ahmadinejad envoys stir trouble at home (9 Sep 2010)

 

Tibetan hope for Obama's India visit (9 Sep 2010)

 

Rusal tries serving up yuan bonds (9 Sep 2010)

 

Turkish strength fragile in referendum run-up (9 Sep 2010)

 

Sri Lanka shuns West, finds solace in East (9 Sep 2010)

 

Searching for yield - at a cost (9 Sep 2010)

 

THE MOGAMBO GURU : Unlimited useless money (9 Sep 2010)

more »

 


Site feed Updated: 2010-Sep-09 07:00