Mar 26, 2011

Finding a Regression for a Circle

I was recently asked to fit a circle to a bunch of data points much like the one right here. You can see that the points are roughly distributed around in a circle of some kind. The task then is to find the equation of the circle which best fits this data.

The Problem

Fitting an equation to a set of data is not an uncommon problem. There´s a large amount of work done in algorithms for finding the ¨best¨ fit for many different definitions of ¨best¨. The person asking me to solve this problem was under the assumption that the normal method, least squares regression, was the best way of going about solving this problem. Actually, performing least squares regression in this case doesn´t really make any sense since the theory applies to only functions. Circles are not functions and so the theory doesn´t apply.

Despite this fact, there was a desire to stick with something like least square regression. I guess it´s like a brand name that people have come to trust. There was talk of some rather complicated solutions, like breaking up the circle into two branches and performing least squares regression on each half in some way, then averaging the results. Anyway you slice it, you´re coming up with an arbitrary algorithm for finding a fit for the function. So really you might as well come up with a sensible arbitrary algorithm.

The solution for the problem is in fact incredibly easy. If you understand what least squares regression is, then you would never attempt to use it for this kind of problem, or anything really remotely close to it.

I resolved the issue with two very clear ideas that cut the Gordian Knot:

  •  The center of the circle is probably around the center of the points. 
  • The radius of the circle is probably the average distance from the center.
The Simple Solution
This is what the end result is when you plot that circle with the data.  It´s probably pretty close to minimizing the absolute residual of the data against the function. The solution is perfect for what it needed to be used for and took about one line of clear Mathematica to program. Relying on math that you don´t understand often causes you to complicate otherwise simple problems.

Feb 6, 2011

Quantum Zombies

The idea the physics induces different kinds of computing must at this point be taken seriously. If were now looking at quantum entanglement in eyes of birds, then the idea that quantum mechanics might have a significant role in the physics of consciousness is not really that crazy of an idea.

As I believe I've pointed out earlier, besides being completely ridiculous by themselves, Kripke's arguments for qualia seems completely useless in the case of quantum consciousness. I wrote a big paper on this subject called "Quantum Zombies". I won't link to it here, since the paper itself is terrible.

Philosophers love to use the analogy of zombies to discuss consciousness. What you won't see in their discussion is any mention that intelligence might have some kind of quantum nature. Like the theory of computation did before, philosophers have assumed a kind of Newton model of physics when discussing these zombies. If their arguments are revisited knowing that the mechanics of thought might involve quantum mechanics, then their arguments about zombies stop making any kind of sense.

For example, Kripke suggests that it would be allowable that there could exist a perfect copy of a person. This copy would be a zombie copy. In a quantum model of thought, this idea of a copy would be ridiculous.

Feb 3, 2011

Design Versus Implementation

The process of software design is often broken up into software design and software implementation. Like all forms of organization and classification, it's inherently incorrect and misleading. It's also necessary for an intelligent conversation on software.

In many of the software projects I've worked on, there has been a tension between these two parts. Very often the roles are separated out and worked on separately, when in a deep sense they are inseparable. The separation of work into design and implementation, architect and foreman, brings about a great danger. If the architect doesn't understand the material and structures houses are built with and the foreman does not understand the purpose of the architect's design, not only will there be conflict, but a chance for holistic creativity is lost. Innovation often requires mastery of both halves.

In popular thought, business people are often guilty of this dilemma. There are many stories of business people who have an idea for the next great website. They only they need to get a programmer to implement their idea. All the hard work to them seems done. The business people are caught unaware of how software was made in practice and become frustrated. Not aware that software creation must be part of the creative process, their projects fail.

Directing programmers is difficult, because software design isn't problem solving. It is problem avoidance. You can ask a programmer to solve a problem, but very often instead she will find a way to avoid it all together. The path of least resistance is often the best and not the one the designer had in mind.

Insert Taoist quote here about how programmers are like water or something like that...
-Laozi


Many have gone so far as to completely discredit the design part of the process. Many stories about internet startups are about how they stumbled into their niche. All they had were quality team of programmers and software designers. They went where their code took them. To some degree this is true. The book, Do More Faster, suggests that ideas are much more worthless than people believe. This is the over arching theme of its first section. Despite the ridiculous name of the book, I recommend it.

The greatest master of both implementation and design might be Frank Llyod Wright. His writings about architecture stress the importance of knowing the whole process of construction. Wright devoted a large amount of his time to understanding the construction methods and materials of his houses and this reflected in his teaching. His college of architecture was known for making students do menial work like carpentry and even farming on top of standard architectural education. Ayn Rand's Howard Roark was a construction worker for much of The Fountainhead. His understanding of the building materials and construction techniques allowed him to innovate where his competing architect's ideas stagnated.

Jan 30, 2011

Japanese Wikipedia

Some things are just difficult to learn unless you´re in the correct setting. Japanese is a good example. A college classroom is okay for learning Japanese, and unfortunately better than what I can do right now. Studying abroad is the only way anyone ever seems to actually learn Japanese and I don´t think that will ever happen for me.

Since I no longer have the burden of college, or the luxury of the being forced to study, I´m at a bit of a loss as to how to maintain my Japanese. I know just enough to make forgetting things really easy, and not enough to make the skill actually useful right now. I didn´t touch Japanese for over 2 years between when I took it highschool and college. I take it as a credit to my character that I didn´t forget it and actually slightly improved over those 2 years.

I don´t know why I bother maintaining my Japanese now. What are the chances of me ever going to Japan? Unless I specifically move there or try to find a job there, I don´t see myself very likely using it. Maybe I like the challenge of learning to write more characters, but I find it hard to justify why I spend time on it. I´ve never been out of the country and hardly left the midwest of America. I didn´t make a choice never to travel. It just never happened.

My friends think this lack of travel experience is a huge problem. I find it hard to see why. Many of benefits of study abroad are things I already consider well within in my skill set. I´ve managed to have a good amount of culture shock here at home. I´ve had to actively seek it, but I have always found it. Despite my lack of first hand international experience, I am a fairly international kinda guy. To my friends though, my apathy to travel is nothing short of a sure sign of an underlying phobia.

Travel reminds me a Zen koan I read somewhere once. Went something like this:

A student once went to see his master. When the student arrived and found the master kept a pet bird in a cage. The student asked the master why they kept the bird caged when it should be free to go where it wanted. The master opened the cage and as the bird flew away asked, ¨and how will the bird escape this? ¨.

Don´t hold me to the authenticity of that Koan. I simply want to use it to illustrate my feeling on travel. I´m pretty sure no one will accept it as an explanation, but there it is.

Once I am in a new place, what will I do there thats different from here? That´s all that really matters to me. Traveling somewhere simply to escape the midwest isn´t really a good way to become free. Of course, this all might be the rationalization of someone who is afraid to travel.

I recently tried to use Skritter to learn Japanese. It´s not for me. I can hear my old Japanese teacher deploring how it doesn´t teach proper writing style. I personally feel like I should be able to study without it.

I recently decided I should read more Japanese Wikipedia. Even better, I should edit English Wikipedia to contain some of the information in Japanese Wikipedia. This would really help my ability to read and make me feel like I´m at least doing something productive (whether this is actually productive is a debate for later). I think that is something I can do and be happy with, even if it´s as close as I ever get to going to Japan.

Jan 9, 2011

Orthogonality

There are some overarching ideas from math that seem to make their way into my everyday life. Orthogonality is one of the newer ones. I've come to appreciate it more recently, seeing it in so many different aspects in so many different areas and applications.

Most engineers and scientists use the term to refer solely to vectors, while the use can be extended to many different types of mathematical objects. The idea however is a very broad one. Parts of code for example can be orthogonal. If changing one part doesn't affect the other parts, this is intuitively like orthogonal vectors. Part of good software design is then a kind of orthogonalization. ( My spell check keeps on warning me "orthogonalization" is technical jargon, but I can't seem to find a suitable expression for it in normal English. )

Analysis is best done by breaking a complicated thing into orthogonal components. This is often an assumed fact. It is clearly intuitive in linear algebra. It is not so clear when it comes to Legendre polynomials for example where it appears to a student that we are adding complexity to make orthogonality. It is not so clear that this makes the computation easier. The best example of the perils of poorly orthogonalized systems might come from statistical modeling in the form of Multicollinearity. A multicollinear model is nothing more than a statistical model whose variables are not well orthogonalized. Multicollinearity is an cause of poor statistical model design in the same way that strongly linked objects are a cause of poor program design.

Nov 26, 2010

Christmas shopping.

There's almost too much that could be written about this. I have a feeling that each person's individual personality is reflected in how they go about finding presents for the friends and relatives.  Some people approach the task with glee and others with dread. Some people demand lists from people of acceptable items, and others give them random garbage they probably already have.

To some degree every person ends up giving a gift that somehow reflects what they think of the receiver. My family doesn't seem keen on giving me books and always tries to find an alternative present. I can't really blame them. Looking at my more recent purchases,  I can't seem to give someone a Christmas present that I wouldn't want myself. It's a terrible curse. Sometimes I often think I would enjoy the gift far more than they will. A bit of greed seeps into my thoughts. The possessive part of me thinks I should buy all the gifts I give in double and keep half for myself. Why don't I have these things for myself? I could never really justify their purchase for my own sake, so I hope others will for me.

Last year there was a special on NPR about how the holiday gift giving frenzy is bad for the economy. The idea seemed reasonable. Focusing so much consumer spending in a short time can't be stable. It makes me sad to see my friends suffer working on Black Friday and even worse, when they have to work on Thanksgiving. Additionally, I'm sure its a huge pain to stock the stores like they must for the shopping season. Please just spread your holiday shopping evenly throughout the year, at least for logistic's sake.

Oh I shouldn't forget:

Oct 16, 2010

Good-bye, Mandelbrot.

As a Mathematician, if you wish to remembered by the general public, make sure your area of study involves lots of pretty pictures.