Saturday, May 31, 2008

Semantic Vectors Revisited (for 31 bucks!)

Its been a while since I posted (been busy writing my new book) and even longer since I've posted any ideas related to my ideas on using concepts from linear algebra to model intelligence. But I thought I'd share an experience that makes me wonder how anything got done before the WWW!

While doing research on tensors for my book I came across a book called MathTensor: A System for Doing Tensor Analysis by Computer. This book describes software for Tensor Math developed using Mathematica so it instantly caught my interest. This lead me to one of the author's web sites which lead me to an article Tensor Analysis of Matrix Cognition during Medical Decision-Making. Now you can't put the words matrix and cognition next to each other without getting my immediate attention so I jumped to that essay which ultimately lead me to this gem: A scaling method for priorities in hierarchical structures by
Thomas L. Sattay written in the Journal Mathematical Psychology 1977; 15:234-281 (there is no online version but you can buy a PDF copy at ScienceDirect if you are willing to part with $31.

I found this research to be fascinating and gave me much food for thought that I'll try to share when I have more time. For now I'd only like to make the following rather obvious observation. If it was not for the web, there would be close to zero chance that I would have found this article and an even smaller chance I would be reading it within 15 mins of finding it. The only sad part is that it is locked up in some obscure journal that I did not have immediate access to without parting with the cost of a nice dinner. I think publishers of journals need to catch up with the rest of the world and begin opening up their older content to free access. Clearly they can use advertising to subsidize this but perhaps advertisement driven business models have reached a point of saturation. Perhaps its time for a library based approach to become virtualized.

I am sure I could find a library within a reasonable vicinity of my home that had access to this journal but who has the time! Why not offer a version that rather than costing $31 to keep forever, costs me $1 to read for a day and $0.50 for each additional day. DRM technology is certainly good enough to make this work. And I am guessing that the publishers would make more money than by waiting for someone like me who was motivated enough to part with $31. There is a vast amount of lost knowledge hiding in these journals. History has shown that the world benefits greatly when such knowledge is serendipitously rediscovered (think Gregor Mendel and his Bean Plants). Its time to unlock the vaults of knowledge so creativity and discovery can reach new unimagined heights!

Friday, May 16, 2008

Real Time Blog Monitoring!!

Part of human nature is to become obsessed about what others think about something you produce. This seems to be especially true with respect to writing. I know many authors (including myself) who have become obsessed with monitoring their Amazon ranking or star rating (I weaned my self off of that one with great difficulty).

Feynman wrote a book titled, "what do you care what other people think?" I never met the man in person but I imagine it would be easier for someone of that stature to not care. I try not to care but often do, much to my displeasure. It is hard for us ordinary people not to measure our own worth through the eyes of others (even if many of these eyes gaze out of even more ordinary heads).

So given this obvious flaw in human nature, what would you say if I told you I found the equivalent of crack cocaine for insecure bloggers! As with other drugs, I found this quite by accident. Some of you may have noticed the little AIM chat widget on my blog. I installed this on a whim more out of curiosity then any thoughts I would spend much time chatting with my few readers. There were only two attempts by anyone to chat with me and both occurred when I stepped away from my computer.

However, what was much more interesting is what happens on the other side of this widget. As you can see from the screen shot above, AIM synthesizes a guest id for every visitor to my blog while my chat client is up. This means every time a new eyeball looks at my blog my AIM client gets updated in close to real time! Further, if you have sounds enabled you hear the squeaky door open and close as they come and go! Talk about instant gratification!!
The real funny thing is that I did not notice all this until someone posted one of my posts on redit! I don't know if the AIM developers thought this through, but I can tell you if folks with far more popular blogs than mine embedded this control in their blog page, the AIM chat servers would get a run for their money!
I'll probably remove the AIM widget from my blog because it serves no real useful purpose. I'd rather folks leave comments that everyone can benefit from than have a private conversation. Still it is interesting what the law of unintended consequences can dredge up. Any insecure bloggers care to "take a hit"?

Thursday, May 8, 2008

The Joys of a Technically Inferior Phone

Recently I lost my cell phone. It was a pretty plain-jane Nokia and my contract was up and so I was planning to buy a new phone anyway. My initial inclination was to buy an i-Phone. I actually went to my local Apple Store with that very intent. Lucky for me they were out of stock.

Several of my friends own i-Phones while others own Blackberries. I was beginning to think I was missing out. However, the out-of-stock condition at Apple gave me just enough time to pause and rethink before caving into my impulse to buy the hot gadget.

First off, I hate AT&T. I did not always hate AT&T but several recent experiences made me swear never to give them my business again. Still, I almost caved and got an i-Phone anyway. Such is the power of techno-lust.

The real reason I'm glad I settled for my new phone (An LG Voyager with Verizon Service) is that it is somewhat cool but nowhere near cool enough. Why is this good, you ask?

Watch an owner of an i-Phone or a Blackberry. I often do. Watch them stroke their phone, caress their phone, slide their thumb wheel or finger their screen. It really makes you wonder what they did with their hands before these touchy-feely phones were invented.

Now, my Voyager has a touch screen and a keyboard. But neither is such a turn on that I feel the need to constantly fiddle with it. So what do I do with my phone? Well, it pretty much stays in my pocket or briefcase until I need to make a call or check my email. I also use the MP3 player.

This is great. My hands are free to do more productive things like doodle on the margins of presentations, scratch my head over some obscure code or even pick my nose when no one is looking (yeah, sure, you do it too, liar).

So think twice before plucking down 400 bucks on a device whose interface is so amazingly fluid you just want to stroke it all day. I am sure you can find more productive ways to use your hands.

Wednesday, May 7, 2008

Nonsense on Stilts

I attended a talk lats night by Massimo Pigliucci related to the debate of when science should and should not be trusted. It was in support of his forthcoming book, Nonsense on Stilts: How to tell the Difference between Science and Bunk.

This was an excellent and well balanced talk that showed how scientists and post-modernists can both get things wrong and what we can do to maintain our BS detectors. I highly recommend listening to it. His web site is called Rationally Speaking.

I probably should not be telling you this...

... but I can't post today because I've come down with a bad case of paralipsis aggravated by symptoms of praeteritio, preterition, cataphasis, antiphrasis, not to mention parasiopesis. So I won't be posting today. I will not stop to mention that my recent posts should have enough meat to keep you busy while I rest.

Monday, May 5, 2008

Red-Black Tree in 2 hours

Many computer science students have heard of red-black trees. If you use any container class library that has a map (ordered associative container) like STL you probably know that red-black trees are a popular implementation of a map. It may be non-obvious why the constraints associated with red-black trees cause them to remain roughly balanced but what is even more daunting is the implementation of such trees in an imperative language like C!

While working on an implementation for a recipe in my forth coming "Mathematica Cookbook" I found a functional implementation in Haskell (postscript) by Chris Okasaki. I know this has been said a million times before but it never ceases to amaze me how succinct and beautiful the functional approach can be. Using the Haskell solution as a guide, I was able to develop a complete red-black implementation in Mathematica in under 2 hours. This may not sound that impressive but consider that the referenced paper does not show how to implemented a remove operation. Even without the need for a remove, how many programmers could take a red-black tree written in say C and translate it into a completely working implementation in Java in under 2 hrs? I suppose a few can but this is really not a post about bragging rights. The functional approach to software development is just god-damn beautiful at so many levels and it is this and not my hacker abilities which made this exercise possible.

Now, there are caveats. There always are. Any C implementation of a red-black tree is bound to have numerous optimizations and a purely functional solution will not fare well for every application of a map (but surprisingly it is competitive for many. I'll post some C++ comparisons when I have a chance.)

If you'd like to learn more about red-black trees but don't know Haskell I would highly recommend learning the minimum of Haskell you need to understand Okasaki's paper instead of trying to learn about them by digging into a C implementation first.

Saturday, May 3, 2008

Which programming language is the most X?

Mailing lists are great places to find fruitless arguments. One of the most chronic arguments take the form of "My programming language is the most X". Here X may be "object-oriented", "functional", or even something much vaguer like "elegant".

When using terms like "object-oriented" and "functional" it is good to have somewhat agreed upon definitions. A characteristic that applies to everything applies to nothing. This is why I get a little bit frustrated when I read arguments like C is object-oriented because you can create tables of function pointers to simulate polymorphism or C is functional because you can pass a pointer to a function. We'll then so is assembler, I guess.

However, almost as annoying are arguments within the group of languages that are widely agreed to have the specified trait. Consider functional languages. I think present day functional enthusiasts would agree that Haskell is an outstanding example of a functional language. It has first class functions, lambda abstraction, and higher order primitives like map, foldr, foldl, etc. However, things begin to go awry when Haskellers start conflating features of the language that, although virtuous as they may be, evolved after the functional paradigm became widely recognised. For example, take single assignment. Clearly single assignment has many benefits. But it is hard for me to accept that the mother of all functional languages, Lisp, is not functional because it has setq. The same is true for other traits like currying, closures, type induction, lazy evaluation, etc.

What gets lost in the quest to define a language as the most X is the much harder question of why the traits that one deems must exist in a X language are important in the first place. In which circumstances will such a trait lead to better software and in which circumstances will it simply provide rope to hang oneself.

The distinction between strict and non-strict functional languages is a good case in point. In a strict language the arguments passed to a function must be fully evaluated before the invocation (ML, Scheme) while non-strict languages can support lazy evaluation (Miranda, Haskell). Is a non-strict language better than a strict one? Should languages support both? Are such questions even answerable?

I think these questions are important and are answerable but the answers involve very deep considerations of problem domain, proofs of correctness, type theory, compiler design and even the limitations of human ability to reason about software. Human knowledge in these areas are not extended by arguments about what's more X.