Sunday, January 27, 2008


Another fairly recent article in the Hokkaido Shimbun 「好調なIT産業」、2008年1月9日、木曜日、北海道新聞(経済)stated that a recent annual report on the state of IT in Hokkaido (sorry, link in Japanese) that the IT business in Hokkaido is growing at a healthy pace. The number of IT employees is growing in proportion to the annual sales figures, and has been doing so since the past 6 years.


From my vantage point, I can understand that IT as a business in Sapporo may be doing well, and there may be a great demand for software developers. I hesitate to use the term "systems engineer", but that's a rant for some other day.

However, AFAIK, things are not as good as the newspaper paints it to be.

First off, the pay scale here in Sapporo for IT has to be the lowest in the Japan. It sure seems that way, looking at my measly paycheck. Try stretching that for a family of four, when the cost of fuel and oil is rising seemingly unchecked, and the effects rippling quickly outward to the prices of groceries and household goods. You know, I had a better salary when I was simply a junior developer back in San Francisco over 8 years ago. I am certain that there are many facets to managing and keeping human resources for a Japanese company, but I still don't get why the salaries up here in the north are so pitifully low.

The aforementioned article does get one thing right, however: it is orders from the greater Tokyo metropolitan that support IT in Sapporo. I fully understood that before deciding to move up here from Tokyo, but I didn't realize that the business model of fishing for gigs in Tokyo and then developing/testing up here in Hokkaido is practically all there is to the game up here. Seriously, there is little beyond that happening up here.

Which is a bit of a shock, coming from Silicon Valley as I did. There are lots of ideas, schemes, grand plans everywhere in the Valley. Start-ups, innovations. Not so here in this little corner of Japan. I almost choked when I overheard someone expressing their desire to market a "security product" consisting of a Javascript hack to obfuscate an email address in order to prevent a bot or script from screen-scraping. Yes, a pure WTF moment. But again, this point could lead me to write some whole other rant, so I will not delve further.

I expect that IT in Sapporo could be suffering for lack of developers due to the fact that most of the good ones probably left for Tokyo. As it is, I hear that coding is now regarded as one of the 3K jobs: difficult, dirty and dangerous. Well, that may be right, but I still feel that there is some way to create an opportunity, to re-invent myself so that I can have that "lifestyle" job and continue to live in beautiful Sapporo.

Nope, don't wanna wear a suit and tie. Nope, don't wanna have to be sitting at some office desk from 9:00 a.m. to 6:00 p.m. just to make some boss feel like he's getting his money's worth out of me. This lack of vision is stifling. Doesn't anyone value the artistry and creativity of software?

And no, hacking up Javascript to hide email addresses from bots is not security!

藤田ブルック?フジタ・ブルック?それとも Brooke Masato Fujita

I was just at the local ward office to get some papers to file with a tax declaration when I remembered to ask the person at the desk a question that has been bugging me for a while.

Can I use my family name in kanji as my official name?

Being of Japanese descent, I actually do have name that is written in kanji. I can actually trace my family all the way back to somewhere in Kumamoto prefecture on the island of Kyushu, in the south of Japan.

However, since I am of US citizenship, as the person at the ward office explained, my official name per my US passport shows "Brooke Masato Fujita". Using the alphabet. Right now, my Foreigner's registration card shows my name using the alphabet, but allows me to also have as 藤田ブルック as my alias. My alias is not official, which means my family cannot use their kanji name. Their names in the Japanese citizens registry (my wife and children have Japanese citizenship) are フジタ. Which sticks out like a sore thumb. Not too many average Japanese use katakana in their names.

So, since I am not Korean or Chinese, which would probably mean that my passport may show my name as 藤田, I have no way of using my kanji name officially. Unless I change my citizenship to become Japanese. And I really cannot see any advantage in changing my citizenship.

What's in name?

北海道 2万人転出超過

A recent article in the Hokkaido Shimbun paper (sorry, related link in Japanese) reports that for 2007, the number of people that left Hokkaido to relocate elsewhere in Japan exceeded 20000. This is an increase of almost 2000 people when compared to the same figures from 2006. Most of these people likely relocated to the greater Tokyo metropolitan, in search of jobs, as Hokkaido suffers from an increasing lack of thereof.

This is similar to the situation in Hawaii, where a brain-drain has been occurring for as long as I can remember. The best and brightest often find themselves leaving because there is not enough to keep them there.

Not that I've lived in many places in the world, but this is still a sad thing, as Hokkaido and Hawaii are two of the most beautiful places to live. For myself, it would be great if telecommuting becomes more wide-spread and acceptable, because then I wouldn't have to tie myself to the vagaries of the current local market situation here in Sapporo. The systems integration company I currently work for has a business model (if you can call it that) that is largely hand-to-mouth, survival only by finding enough gigs to build smallish web-sites and then try to charge a recurring fee for support and administration. I don't think this scales at all.

Adapt. Improvise. Evolve. It is high time to think, rethink, and reinvent.

Sunday, January 20, 2008

Pi, Probability, and Python

π and probability theory intersect more often than you would expect. The mix gets more interesting when you combine that with a quick look at math history, and toss in a short program as well.

Buffon's Problem
George Louis Leclerc, Comte de Buffon (1707-1788) was a general scientist, mathematician, and gambler, as well as a man of means with time to spare on interesting math problems. One which he put forth and subsequently solved was this: Given a needle of length L, to be tossed upon a horizontal planed with parallel straight lines separated uniformly by a distance d, what is the probability that the needle will intersect with one of the lines?

Assume that the position and orientation of the needle are two variables that are random and independent. Let the distance from the needle's center to the nearest line be x, with the orientation of the needle being the angle φ created by the needle intersecting the line in question. Consider x and φ per the needle's intersection with a single line, since all intersections with any other line will be the same.

Now from the figure above, it can be seen that the needle will intersect a line if and only if

x < ½ L sinφ

Therefore, Buffon's problem can be resolved by finding the following probability:
P(x < ½ L sinφ)

In order to find this probability, we can visually represent this by graphing with the rectangular coordinates x and φ, where
range: 0 < x < d/2
domain: 0° < φ < 180°

Given these intervals for x and φ, any point that lies within the parallelogram described by points A and B correspond to one and only one position and orientation of the needle thrown. Furthermore, since all such combinations are equally probable, the area of AB represents the sum of all probable outcomes for the thrown needle's position and orientation, with the area under the curve x < ½ L sinφ representing the sum of all possibilities where the needle intersects a line.

Hence, the probability that the thrown needle intersects a line is the ratio of the the sum of possible outcomes where the needle intersects a line, to the sum total of all possible outcomes. This can be expressed by:

Laplace and the Monte Carlo Method
Pierre Simon Laplace (1749-1827) saw Buffon's solution from a different perspective, which gave rise to a new method in computing. From that last expression above, Laplace generalized it to:

The end result was a new method whereby π could now be calculated by determining the probability P. The calculation is simplified if one sets d equal to L. But the key point is that Laplace discovered a method whereby a numerical value is found by realizing a random event many times and observing the outcomes. This method is known as the Monte Carlo method.

So where does the Python come in? I wrote a method in Python for computing π in Monte Carlo fashion:

from math import *
from random import *

def execute():
count = 0.0
step = 1000.0
for i in range(1, 10001):
for j in range(0, step):
x = 0.5 * random()
phi = randrange(0, 180, 1)
if x < 0.5 * sin(radians(phi)):
count += 1
P = count/(i * step)
print "%d: P = %0.25f, pi = %0.25f" % (i * step, P, 2.0/P)
print "all pau!"

This runs a Monte Carlo simulation of 10 million throws of the needle, computing the probability of intersection every 1000 steps of the way. One execution yielded the following output:

9995000: P = 0.6366198099049524827819369, pi = 3.1415924683503022585284725
9996000: P = 0.6366196478591437113436768, pi = 3.1415932680144256217147358
9997000: P = 0.6366192857857356779405222, pi = 3.1415950547767912404140134
9998000: P = 0.6366201240248049453285262, pi = 3.1415909182319108339243030
9999000: P = 0.6366206620662065995830403, pi = 3.1415882631091953669510985
10000000: P = 0.6366190000000000459579041, pi = 3.1415964650756573739442956
all pau!

Hm... only correct to 5 places after 10 million trials? I think I may have to see about calculating the probably of computing π to n places in t trials. While it may not be all that efficient for calculating π, the Monte Carlo method is nevertheless a powerful approach for resolving problems with incredibly large sets of computer-simulated trials.

With inspiration from
A History Of Pi, P. Beckmann
History of Mathematics, D.E. Smith

Saturday, January 5, 2008


pol·y·glot (pŏl'ē-glŏt')
adj. Speaking, writing, written in, or composed of several languages.

1. A person having a speaking, reading, or writing knowledge of several languages.
2. A book, especially a Bible, containing several versions of the same text in different languages.
3. A mixture or confusion of languages.

[French polyglotte, from Greek poluglōttos : polu-, poly- + glōtta, tongue, language.]

Stevey, in a long but well-put rant on code bloat, exposes an issue which I have been wrestling for the past several months:

But you should take anything a "Java programmer" tells you with a hefty grain of salt, because an "X programmer", for any value of X, is a weak player. You have to cross-train to be a decent athlete these days. Programmers need to be fluent in multiple languages with fundamentally different "character" before they can make truly informed design decisions.

Recently I've been finding that Java is an especially bad value for X. If you absolutely must hire an X programmer, make sure it's Y.

This is absolutely true. I must admit that my résumé and work history really only show my roots in Java. But being an autodidact and wannabe polyglot, I can definitely see that I need to be cross-training. To that end, I am presently pursuing knowledge in the following languages:

  • Ruby: I have written a very small web service in Ruby and Ruby on Rails in my "day job". Rails is OK, if your requirements fit the "sweet spot" that Ruby On Rails proclaims to hit, but Lord help you if you need stuff, like, say, composite keys.
  • Python: Before Ruby, I stumbled across Python. Kevin, if you're out there reading this, thanks for a) telling me about Guido van Rossum and b) introducing me to Cygwin ("it makes Windows useful")
  • Common Lisp: from my short experiences with mathematics, I have learned to appreciate elegance, and Lisp is nothing if not elegant. David, if you're out there reading this, I apologize for not recognizing the truth in your words and conviction any earlier. But I still have not gotten the hang of Emacs yet...

Thursday, January 3, 2008


We are 3 days into 2008 (平成20年), and already I have found a lot for which I can be grateful, a lot that make this shiny New Year special. We were driving out to Kushiro to visit my In-Law's when we spun out on an icy patch and went straight into a guard-rail on the expressway exit near Yubari. No one was hurt, and the only damage was to our tough little Toyota Sienta. It was the second ambulance ride for my poor 2-year old son in the space of a week, but thankfully, in both cases there was nothing wrong.

Family. Friends. All the people you love. That's what really matters. All else can be replaced.