home
on exploration, introspection and creation

Archive for October, 2009

0.2 second commercials

Thursday, October 29th, 2009

I don’t know if it’s just Cablevision but often, the very last ad during a commercial break lasts for a very short period of time — just a fraction of a second. I’ve always wondered why this was so.

The most likely reason is probably a poor implementation (I was going to write “a limitation of technology” but since everything is possible–it just comes at a cost which may not be worth it). I’m guessing that since the commercials come from a variety of streams — nationwide ads, local ads and Cablevision’s own “propaganda” — the system that splices them together isn’t quite synchronized with the overall system that determines when commercials should begin and end.

But the crazy in me sometimes thinks this is actually done on purpose. A kind of “subliminal advertising” option that costs less than a regular commercial (duh, it’s so much shorter!). This is especially tempting because if it were true, the fact that I’m writing about it means it actually works!

I also wonder whether the companies are charged for these microcommercials.

Absolute and Relative Happiness

Wednesday, October 28th, 2009

What is happiness? My friend P.W. and I were talking about it some time ago and we found it difficult to agree even on the most fundamental characteristics of happiness. It was clear to both of us that happiness is subjective (the best way to assess whether somebody is happy is to ask them); in fact, the subjectivity is pretty strong: a lot of the factors we considered (wealth, intelligence, family, physical appearance, health) didn’t seem obviously related to happiness–we could think of plenty of frequent situations where added wealth didn’t make the person any happier, for example.

When I think of happiness, I imagine a two-dimensional model. One dimension is the person’s capacity to perceive happiness. This capacity changes over time, varies from person to person, but it changes slowly. It defines a sort of spectrum. The other dimension is where in that spectrum the person is currently perceiving themselves to be. Essentially, at any given point people are somewhere between very unhappy and very happy, but those limits change over time as people realize how much happier (or how much more unhappy) they can be–either because they understand the world better, or see additional opportunities that they haven’t seen before, get hardened in life, or simply experience more. I think a significant hurdle people encounter when they talk about happiness is that these two dimensions are frequently confused. It’s not clear to me, for example, whether what we frequently refer to as “happiness” is the first dimension (the range of happiness), the second dimension (the absolute happiness), or some combination of the two. A simple yet useful way to think about these dimensions is to imagine a scale going from X to Y (the range) and a pointer Z somewhere between X and Y (absolute happiness). There are three quantities we may care about: Y (or X) (the extremes of happiness and unhappiness that we can conceive of), Z (happiness on an absolute scale), or (Z-X)/(Y-X) (a notion of where we are relative to the range: happiness on a relative scale).

If we use this framework for understanding happiness, we’ll see that increasing your range (i.e. discovering what it means to truly be happy) lowers your relative happiness. You can see this fairly easily if you think about a frequently cited adage “Ignorance is bliss”. Would you rather lead a life where you are happy but don’t have much of a conception of the complexity of the world around you, or lead a life where you are not so happy but are aware of what surrounds you, understand the world, and can perceive how much happier you could be relative to the other case. Would you prefer your happiness range (Y-X) to be small and your relative happiness to be large, or vice versa? In other words, do you care about absolute happiness or relative happiness?

What is conceptual thinking

Monday, October 26th, 2009

To me, conceptual thinking is simply the ability to effortlessly walk up and down the ladder of abstraction.

I think a lot of people think that great conceptual thinkers have more abstract thoughts than non-conceptual thinkers. I don’t think this is sufficient. Don’t get me wrong — abstract thought is good, and those able to think abstractly are able to solve problems easier (a lot of the details that are unimportant for the problem go away–many problems, when seen abstractly, also turn into similar problems that are more tractable), learn faster (since they can make deeper connections) and are probably less anxious in life (deeper understanding, no annoying and distracting detail, etc.).

But someone who is just an abstract thinker isn’t actually all that useful. For one, they simply can’t communicate with those who can’t think abstractly — which is the majority of the population. They are also probably unable to turn their thoughts into reality, because, like it or not, reality is concrete and not abstract.

To make their thinking useful, abstract thinkers need to be able to convert something abstract into something concrete, and vice versa. This ability is what I call conceptual thinking. A conceptual thinker starts in the concrete, then walks up the hierarchy of abstractions. At some level they make connections between the abstract representation of the concrete thought and another abstract representation. If need be, they can then walk that abstract thought back into another, very different concrete thought. The idea is that a local search (i.e. making connections) in the abstract space is easier than a local search in the concrete space. And so that person can either communicate more effectively, or solve the problem more effortlessly.

For example, suppose I have to solve a difficult puzzle. If I am a conceptual thinker, I can turn the problem into a more abstract one (recognize it as an instance of a more generic class of problems). The “abstraction tree” is more narrow the higher you go (because each time you walk “up” the hierarchy, you extract an equivalence class–there are fewer equivalence classes than instances those classes represent) so you’re more likely to have seen the more abstract problem before than the specific one. That way, instead of solving hundreds of puzzles in hope that in the future you will encounter one, you really just need to solve one per equivalence class.

I make it all sound so easy. Unfortunately, it’s not. I’ve replaced one ability (the ability to solve a concrete problem) with another (the ability to turn concrete things into abstract things, and vice versa). The latter is a generic ability, which makes it hard. The higher the abstraction tree you go, the harder the walk becomes–which makes sense, because the higher the abstraction tree you are, the fewer equivalence classes there are (so solving problems should be easier–fewer things to compare).

An interesting thought experiment is to take this to its logical extreme — it’s possible to have the ability to walk so far up the abstraction tree that there really is only thing, only one equivalence class. Every thing, every thought, every idea is equivalent to every other thing, thought, and idea. It’s a fascinating concept which I’ll be exploring much more in dedicated posts. Right now though, just think about it.

What is Intelligence (part I)

Sunday, October 25th, 2009

What if intelligence was simply the ability to convince others you’re intelligent? I know it sounds like a cop-out (isn’t any recursive definition a cop-out) but with so many wildly different theories about what intelligence really is, it’s by far not the most unreasonable one.

This brings me to an interesting thought on how intelligence should be measured. The intelligence quotient test (you know, those puzzles) has been criticized widely as both suffering from false positives (you can train yourself to solve these brain teasers and puzzles; they are fairly predictable and being able to do them doesn’t necessarily make you intelligent) and false negatives (people who don’t have strong verbal skills will be deemed “unintelligent”). How about I measure intelligence by asking everyone how intelligent they think everyone else is. I would then weigh the opinions by how well each reviewer knows the reviewee, and by how intelligent they were deemed to be. This is recursive, yes, based on a hypothesis that intelligent people can gauge intelligence better than unintelligent people.

How exactly would this work? Say I send out a survey where I ask everyone to place everyone they know in one of several “buckets” (equivalence classes) based on how intelligent they are. Bucketing is my favorite way of assessing things — the problem with the ranking is that it takes too much time and often ends up being arbitrary (it’s much harder to answer the question “is person X more intelligent than person Y” than the question “is person X by and large as intelligent as person Y”); the problem with some scale is, again, that it’s arbitrary to begin with, and that it either requires some kind of reference point at which point it simply becomes a ranking, or it’s a heuristic, at which point it suffers from the same problem as IQ. If there aren’t too many buckets, this exercise is not particularly hard.

Then I figure out how intelligent everyone is by collating people’s reviews of them. I would weigh the reviews based on how well the person knows the reviewee (again, on a 5-point scale or something)–i.e. how confident that person is of his/her read of the reviewee. If the population is large enough, this resultant intelligence level will be pretty granular (much more granular than the number of buckets we started with). Now, since I’m assuming that intelligent people can tell intelligence better, I’d go back and weigh the opinions by how intelligent each person is. This will change the intelligence “score” slightly — so I feed the new scores back into the weighing, and so on, until the entire process converges on some numbers.

I don’t know yet — it’s a very interesting question — whether it will always converge, but my guess is that it will. It will definitely not diverge (since the intelligence score is bounded). It may oscillate.

The Metric system vs the Imperial system

Sunday, October 25th, 2009

This must be the most popular topic of conversation whenever a bunch of Europeans get together…

The U.S. adopted the English (I’m so rubbing it in) system of measures several hundred years ago and while the rest of the world (including Great Britain) moved on, going with the Metric system instead, we stuck with the good old pounds, inches, and ounces. As is the case whenever an entity used internationally lacks international standards, it’s been causing loads of confusion and even disasters. Besides asking why this is so (the United States is uniquely insular in this respect, even more than actual islands such as Japan or Great Britain where such a thing would have a natural justification), a lot of people engage in the oft time-consuming and fruitless rhetoric of which system is superior. I’m going to add to this hairball, but only a little bit. And I’ll try to use first principles rather than dogma (we’ll see if I succeed).

The goal of having a standard of units are to provide a common framework for the society to efficiently and robustly (i.e. in a way that’s resilient to errors) convey information about measures that doesn’t require special skills (i.e. to make the framework usable by as many people as possible).

I think there are two factors one must take into consideration when comparing the two systems: the intrinsic properties of the units (how practical they are in daily use) and the way they can be manipulated and composed (how to multiply them, compare them, convert them). I claim that the Imperial system is superior at the former, and the Metric system–at the latter.

What makes Imperial units intrinsically superior is the very choice of how much a primitive of various frequently uses measures actually measures. I think an inch is superior to a (centi)meter — I’m sure that if we were to take a survey of all lengths that humans refer to in their lives (controlling for a selection bias–people will tend to round up or down to the nearest unit of whatever system they are using), and draw a histogram of such usage, there would be a peak around the inch and not the (centi)meter. I’m even giving the Metric system the benefit of the uncertainty around which unit specifically should count as the primitive. In other words, we’re more likely to talk about things which are the size of an inch than things which are the size of a centimeter. Similarly, the (mili)liter is inferior to a fluid ounce — a fluid ounce is a more natural measure of a “splash” of a liquid.

There is a second-order effect of measures around, not at the primitive: do things more naturally come in (sub)harmonics of an inch (“half an inch”/”one-quarter of a pound”/”three ounces”) or the meter (“three centimeters”/”one-half of a liter”). This is probably much harder to determine. However, one important property of the Imperial system is that it operates primarily on natural and not decimal fractions of units. The Metric system talks about 0.2 centimeters; the Imperial system talks about one-eighth of an inch. Natural fractions are (even by the very definition) more engrained in the human nature than decimal fractions–we’re used to thinking about dividing things into equal parts and visualizing individual parts than dividing into a fixed number of parts (10) and visualizing multiples of that fraction.

The most important benefit of the Imperial system, in my view, is that it operates (mostly) on base 12 and not 10. I already wrote about how base 12 is far superior to base 10–it divides cleanly into 2, 3, 4 and 6. Base 10 numbers divide cleanly only into 2 and 5. Having intrinsically more divisors is better because it avoids awkward infinite fractions and, ultimately, inefficient communication.

When it comes to the second factor, though (how the units are manipulated and composed), the Metric system wins hands down. The Imperial system is inconsistent (12 inches to a foot; 16 ounces to a pound); there are far more units to remember (fluid ounce, pint, quart, gallon) and more units to remember the relationship between. The Imperial system captures many fewer measures at the very small and the very large range — in fact, the only way to represent very small or very large numbers is to use the multipliers that are the very foundation of the Metric system (10 million pounds, for example)!

Most of the disagreement, then (especially when a bunch of Europeans get together…), can be boiled down the the philosophical difference (I define a “philosophical difference” as a difference in opinions that cannot be reconciled with logic because it’s simply too costly to find a way to compare the opinions objectively) — do you prefer the intrinsic properties of the units (which I feel are more aligned with human nature), or the composition properties of the units (which are more aligned with civilization).

On diagnosing problems

Thursday, October 22nd, 2009

The ability to diagnose problems is one of those incredibly useful skills to have in life. From experience and observation, I can say that very few people possess it. While it’s a bit of an art, there are some simple principles that people just don’t seem to apply.

You may think that diagnosing problems is an ability that’s really only useful in a narrow domain, such as programming or fixing cars. But we come across problems all the time, even when we don’t realize it (A clogged drain in the bathroom. Tivo doesn’t want to record your favorite show. You don’t seem to be losing any weight despite being on a diet). So here are the basic principles. Nothing in here will be a surprise to anyone; the bulk of the work is in internalizing those principles–and being able to apply them when solving problems.

Define the problem.
What is the problem exactly? Can you concisely yet precisely formulate what the problem is? If you have to use words such as “broken”, this is usually an indication that you haven’t really defined the problem well. How does the problem manifest itself? It’s very useful not to mix diagnosis with the formulation of the problem; at this point your diagnosis may not be correct and you may be incorrectly leading yourself down a wrong path from the very beginning. A useful trick is to try to simply phrase the problem as something that constrains you, i.e. something that prevents you from doing something.

Replicate the problem.
Can you show me the problem manifesting itself? Most problems in the world are easily replicable; for example, if the TV doesn’t turn on, it doesn’t turn on. But some problems are more tricky than that–maybe your brakes make a noise only when the engine has warmed up enough; if you just turn the car on, you won’t hear the noise. Being able to show the problem occurring is very useful as it allows you to test your theories easily. Note that at this stage you don’t need to figure out all circumstances under which the problem occurs: you just need one.

Contain the problem.
Try to replicate the problem with as simple a setup as possible. This will eliminate a lot of the factors that would otherwise have to be included in the diagnosis. A lot of people either assume that most of the steps they did are necessary for the problem to occur (very rarely is a problem a coincidence of a large number of factors), or assume that most of the steps they did are irrelevant (surprisingly frequently is a problem due to something that one implicitly rules out early in the diagnosis stage).

An Aside: on Theories
Note that while you will certainly run across theories about the problem as you try to replicate it and contain it (and sometimes even define it), you should be careful not to jump to conclusions too quickly. I think a lot of smart people are also lazy, and this combination manifests itself as impatience when diagnosing problems. There’s nothing wrong with having theories, and in fact, experienced diagnosers will be able to come up with a theory with very little information. But what I see a lot is people coming up against a problem they can’t solve and struggling to solve it because they are either stuck with theories that don’t work and can’t find better ones, or went down the wrong path early on in the diagnosis (when I was a teaching assistant in a computer science class back in college, I would help students find bugs in their software. They would be taken aback at the simple questions I asked them; “Of course that’s not the problem,” they would say. I’d tell them, “If everything is an ‘of course that’s not the problem’ yet you can’t fix the bug, at least one of the ‘of course that’s not the problem’s is probably the problem”.

So hold off on theories for as long as you can–if you ran across a hard problem (which is really the domain we’re interested in here), you are likely to want to solve it, and only as a second-order thing to solve it quickly.

Locate the problem.
Chances are, by now you probably will have located the problem to a large extent. If you haven’t, it’s the natural next step: determine where the problem lies. There is only a subtle difference between locating a problem and testing theories, so you will invariably be doing the latter as well. Start with your (small) setup needed to replicate the problem. Vary your setup to draw conclusions about where the problem is (or, more likely, where it is not). This will help you narrow down a set of theories that you will have to try out by a substantial amount. It’s a good idea to do easy things first (to gather as much information as possible about the location of the problem), but of course there’s a bit of an art in trading off cost of the experiment against the expected amount of useful information it will give you.

For example, I once had a clogged drain in my sink. Here is what I did–compare this with the steps above:

  • The problem was this: the sink would accumulate water quickly so I couldn’t have the tap running too long or I’d flood my bathroom.
  • I could easily replicate the problem by turning on cold water to its maximum and waiting for one minute. The sink would fill up with water.
  • I noted that I don’t need to use cold water; hot water would do as well. I also didn’t need to turn it up to the max–at some point (maybe half way through) water would start accumulating
  • Locating the problem is one of my favorite parts of diagnosis. First, I poured water down the “safety” drain located on the upper part of the sink (the one that prevents the water from spilling out of the sink). I could not replicate the problem. This means the problem is somewhere between the hole in the sink and the part where the drain meets the safety drain. This is great because I no longer needed to unscrew the “U”-shaped part in the drain (it was below where the safety drain flows). If I had started with a theory (“there’s probably a bunch of disgusting stuff blocking the ‘U’-shaped part”), I would have wasted some time.

Note that normally we just do this all implicitly, in our heads, but there again, a clogged drain is not a hard problem. It’s a good idea to be a little pedantic once to get a feel for what diagnosing problems well means.

Finally, form theories and test them out
If you’ve gotten to this point, you are likely dealing with a hard problem. Good!–because this is where the most art comes in. The hard part about forming theories is that you have to find theories that help you prune your search tree as much as possible, in as cost effective way as possible.

The “search tree” thing is very important. I cannot stress it enough. Each theory you test eliminates a class of problems. So if you imagine the set of all possible problems, each theory you test in the sequence will eliminate a subset of them. It’s much better to eliminate most of the problems first (this gives you fewer problems left, so fewer theories to test). It’s a little bit like the game of 20 questions–it’s better to ask a generic question that eliminates half the possibilities first, than a specific question that with high probability eliminates a very small set. Of course you don’t know the probabilities or even the eliminatory power of your theories so this is where the art comes in. You have to trade off three things:

  • How expensive is it to test your theory?
  • In the best case, how many problems can the test eliminate?
  • How likely is the best case?

Again, if you’re stuck with a problem, you will likely not care about being the most efficient so really you should strive for your theories to simply eliminate as many potential problems as possible (ideally in a balanced way, just like the questions a good “20 Questions” player would ask).

The nice thing about a problem tree that you thus construct is that if it’s balanced, you will not need to test many theories — just like 20 questions should be enough to find a thing from amongst a million things! However, one thing I see people do over and over again is forget where they were on the tree and either redo many tests, thus getting no useful information, or perform tests that are irrelevant given where in the problem tree they are (for example, if I tried to see if the “U”-shaped part is clogged after I figured out that it’s not the problem).

Behavioral change (part II)

Wednesday, October 21st, 2009

In my previous post I extolled the virtues of behavioral change. Here’s a couple of small things I’m doing–they are a kind of “grassroots” way of training myself to be flexible.

  • I replaced milk chocolate (which I absolutely love) with dark chocolate (which I didn’t use to like)
  • Everyone calls one of my friends M.T. by his nickname. I decided to use his real name instead. No cheating!–I use his name at all times, even in notes to myself
  • I used to wear way too little when it was cold and thus permanently feel cold. I’m making myself wear one more layer

These are fun little experiments; I encourage you to try some yourself. Observe yourself for a day or two and note things you do frequently. Then resolve to do some of them differently. It doesn’t have to be permanent–perhaps a month or so–but it should be long enough so the change doesn’t get contributed to luck.

What being 25 years old taught me

Tuesday, October 20th, 2009

For a historical note, check out the post on the life and death of the “25-while-25″ plan.

The thought that resonated the most in my mind as I was turning 25 was that two years had passed since college and I hadn’t really been striving for anything. It seemed different than my time in college, which was filled with non-academic activities. I didn’t want to become complacent with life, just kind of let things go, in fear that I would let my life crawl past me.

The result of that thought (fear) was the plan to achieve 25 things while I’m 25. Half way through the plan, I changed it to be less a random collection of items and more like a goal tree, each goal being derived from the few things that I really cared about. What I really cared about then were two things: knowing what my purpose in life is, and proving to myself that I can execute on goals. Now that I’m no longer 25 it’s time to retrospect.

A question that people have been asking me for a while now is “so how many items did you achieve from the list?” It’s a good question; it gives one an idea of either my follow-through, or my ambition (or both). I did 15.

I will focus on those achievements that I think taught me the most. For one, several of the goals had to do with a behavioral change, something that’s overall very difficult to do and usually takes a lot of time. I started leading a much more active life (running the half-marathon–and the marathon, but that was after I turned 26–and taking up swimming were examples of the goals which required the change; I also did some crazy things like bike to Manhattan and run to work, which was fun). I’ve gotten to the point where the default modus operandi is for me to go running, or swimming, or biking — without it I feel like my day isn’t complete.

That one was the most striking example of behavioral change. There were other goals in that category, which I achieved, but which still don’t feel natural. Reading is one of them (my goal was to read 50 books). I also vouched to be less angry at people (and things), and to deepen my friendships with people I care the most about.

Another big achievement was beginning to think. I realized that I haven’t been thinking nearly as much as I should have been (in general, I realize I should adopt a philosophy of contrasting my thinking and my doing–letting one feed off the other, and improve based on the other. Too much doing caused me to stop learning, to waste time doing the same things over and over again; but if I let the pendulum swing too much and just think, I’ll lose the much needed feedback that I can only get by applying my thoughts).

Specifically, I started thinking more seriously about my life’s purpose and while I haven’t achieved the overarching goal (of determining my goal in life), I went very far from where I was a year ago. Starting a blog–and holding myself accountable to updating it regularly–helped a lot; I was able to give shape to many thoughts I’ve had around the life purpose, and in general around metareasoning.

Finally there were goals which had to do with changing my perspective, doing something unusual, committing to something that may not necessarily be something I’m most comfortable with. Summiting Mount Kilimanjaro, becoming a regular at a bar and going racing on ice in Colorado were examples of such goals. To release elevenseconds.com I started using ruby. I made myself drive stick. I came to terms with owning a car that’s not quite practical.

What was the outcome of all this? First of all, I feel like I haven’t wasted a year (curiously, the year seemed to pass much more slowly than my twenty-third and twenty-fourth year… I felt fully in control of my life, which I don’t think I could say about the previous two years that have kind of passed me by). I started thinking more (which should hopefully help me figure out my purpose in life, one of those days…). Overall I feel that I’m less anxious (having a site/blog means that I can start sharing out what I’ve done and thought about; having started hard things means that I can still adapt).

The next frequently asked question is “what will you do for your 26th year?” No, I’m not going to be trite–there will be no 26 things. Instead, I will focus on some remaining things, high-level goals that I didn’t get to that still cause some anxiety. I think I’ve captured a good framework for this here, but by and large I want to focus on:

  • Being creative — I haven’t gotten to do many of the items on the 25 list that dealt with creativity, and I feel that I don’t really have an outlet for creativity these days
  • Doing something that lasts — I want to apply the “step back” test when I’m turning 27
  • Being flexible — this means both in terms of being able to change (continue working on behavioral change–make reading a natural thing, continue leading an active life) and in terms of starting new things, particularly hard things (do miniprojects on weekends)
  • Figuring out my purpose
  • Exploring more, seeing more, experiencing more — doing things from my bucket list
  • Sharing — there’s still so much that’s in my head (and on my computer) that I want to share with everyone

The zoom effect

Monday, October 19th, 2009

As I considered the best way to display series of pictures on the main page, I came up with an interesting way to compress a lot of information onto fairly limited screen real estate. The idea was to have a kind of a slide show composed of small icons that turn larger as you hover over them; clicking on any icon would bring up with full-size image. That way I could fit a lot of small (32×32 pixels) icons of images on the screen, yet offer the users the ability to browse larger versions (67×67 pixels) easily just by moving the mouse around. The idea, of course, was inspired by what OS X does with the Dock (an effect which, sadly, I have disabled on my computer–but due to different use scenarios). Check out the effect in action here.

The design process I went through is an interesting example of discovery (or serendipity, rather) and how taking an analytical approach doesn’t always yield the best results.

The desired effect will be very familiar to you if you’ve used OS X and the Dock. I want to display a series of small thumbnails of images in a row. If you hover over them, the image that your mouse is closest to gets larger, pushing out the other images if necessary. I wanted the effect to be smooth (so as you move your mouse over the row, images get bigger as they approach the mouse pointer, and then get smaller) and resemble something like this:


zoom-1zoom-2

The Zoom Effect

There are three variables that I need to be concerned about: how much to magnify the icons by (in my case, I wanted to go from 32 pixels to a maximum of 67 pixels), how far out the magnification should affect the icons (in the picture above, the icons two to the right of the center icon are no longer magnified), and how quickly the magnification should drop out (how “drastic” the magnification of the center icon should appear). For each of the icons in the row, I need to figure out how much to magnify them (by convention, let’s say that 1 is full magnification and α is the regular, small size) and where to place them horizontally (because they will push out other icons), subject to the constraint that the icons must remained aligned in a row.

An analytical solution was easy to get to, but very quickly spiraled out of control, and here is how. Let’s consider two configurations:

  • When the mouse cursor is exactly in the center of an icon, by symmetry that icon should have the maximum magnification:
    Maximum magnification at center of icon

    Maximum magnification at center of icon

  • When the mouse cursor is exactly in between two icons, also by symmetry both icons should be of equal size:
    Equal magnification in between two icons

    Equal magnification in between two icons

Depending on β, the magnification will drop out quickly (if β is close to α) or slowly (if it’s close to 1).

Since we want the magnification of the icon to be a smooth curve (as the mouse pointer moves across the icons), we simply need to define a continuous function given the three points it goes through: (0, 1) (because at x=0 — i.e. when the mouse cursor is exactly over the icon’s center, we want the magnification to be maximum), (α/2, β) (because when we’re in between two icons — i.e. a distance α/2 away from the center of one — we want the magnification to be β) and (Z, α) (the distance at which all magnification ceases). An exponential curve is the simplest one that we can try:

Magnification as a function of distance from the icon's center

Magnification as a function of distance from the icon's center

We will then be able to use this curve to determine how much to magnify each icon by. The icons will be sized such that their size given the distance between their center and the mouse pointer can be read off of that magnification curve:

Applying the magnification curve to each icon.  Past the point <i>Z</i> all icons retain their original, small size

Applying the magnification curve to each icon. Past the point Z all icons retain their original, small size

First let’s figure out the full form of the magnification curve. The curve must go through the two endpoints we identified, and be exponentially decaying, so it is of the form

y = 1 – (x/Z)P(1-α)

(We can verify that at 0, y=1 and at Z, y=α). We need to compute P based on the third point:

β = 1 – (α/2Z)P(1-α)
P = logα/2Z( (1-β)/(1-α) )

The first icon is simple: determine the distance between the mouse pointer and the center of the icon and use the curve above to read off the magnification (it will be something between β and 1). The subsequent icons are a little more tricky, because in order to figure out the magnification you have to know how far its center is from the mouse pointer, but the position of the center is a function of magnification! At this point the easiest thing to do is to solve this numerically, by simply iterating over all possible positions of the center and determining the closest one (since we’re operating in a discrete space with the smallest effective resolution of 1 pixel).

While each step seems fairly straightforward, the end result is a pretty big hairball. Being lazy, I realized that there must be a better solution to this problem.

And then I realized that so long as the illusion of smoothness is preserved, some simplifying assumptions can be made. First of all, the exponential curve I used initially was too complicated and looked too discontinuous at large magnifications (because of a sharp spike near 0); there must have been something else that’s straightforward to compute. The parameters seemed complicated, too — α and Z could be replaced with just one — a measure of how quickly the magnification should decay — without much loss of the effect.

The Normal curve came to mind — with just one parameter (σ) it was much easier to experimentally determine a value that had a pleasing effect (plus, σ is by definition very close to our notion of “how quickly this should decay”). I also got rid of the self-referential problem (determining magnification requires knowing origin, but origin influences magnification) by looking at not the actual distance (how far is the icon from the mouse pointer after all icons have been magnified), but original distance (how far is the icon from the pointer before magnification).

The resulting algorithm is much more elegant — and produces a more visually pleasing effect:

  • For each icon in the original (i.e. before any magnification takes place) series, determine how far its center is from the mouse pointer (I experimented with just using the x-coordinate, but the nice thing about this algorithm is that any smooth function works, and the actual distance produced a nicer effect than just the horizontal distance)
  • Use the Normal curve to determine its magnification. We want the result to be 1 if the distance is 0 (i.e. the icon is directly under the mouse pointer) and α if the distance is infinite (since the Normal curve dies off quickly, the size would go down to α pretty quickly as well), i.e.

    N = e-d*d/2σ*σ
    M = N+α(1-N)

  • Place each icon with its magnified size on screen; keep track of how much space each icon took so that subsequent icons can be displayed after it and not on top of it
  • Technically this is enough for magnification. However, this doesn’t produce a smooth effect: since the icons are always pushed out to the right, the “tail” of icons keeps traveling back and forth. We want the entire series of move smoothly, slowly to the left as the mouse moves to the right (go here and watch the icons at the end of the series travel to the left as you move your mouse pointer left to right, across the icons). This is simple to correct, though: keep track of how much space all the icons take (by adding up each size as you go), and then offset all the icons by a fraction of that total space, depending on where the mouse pointer is: suppose the icons originally take d pixels, and expanded they all take D pixels, and the mouse pointer is at position x (between 0–at the beginning of the series–and d), we want to offset all icons by

    x*D/d

To check out the source code for this effect, see ui.js, a javascript file that includes a function shiftImages (I know, bad name) to magnify all icons based on the position of the mouse pointer.

You can also download all diagrams on this page in pdf form and in LaTeX.

The purpose of chance

Sunday, October 18th, 2009

What if chance is nothing other than noise, a necessary artifact of the complexity of the Universe? What if chance, given powerful enough driving force, could simply be ignored (and hence luck made irrelevant)? How would this change our lives? Would we still spend extraordinary amounts of time, effort and money to isolate chance, seek the kind that works to our favor, and make our life decisions based on it? Would we realize that we are so preoccupied with chance–the second order effect–and are paying no attention to the important things in life (after all, losing sight of the goal and focusing on the unimportant details only because they are more concrete and easier to fathom is undeniably part of human nature) that determine our path in the universe?

Why would one liken chance to noise? Chance, just like noise, carries information. Noise appears in any sufficiently complex system due to effects that we either don’t understand, or don’t want to harness (it may simply be too expensive to reduce noise in a cable due to heat because with a strong enough signal we can have the cable carry enough useful information). Similarly, we talk about chance (or luck, which we’re using interchangeably but probably shouldn’t) when we mean things that happen to us in life that we don’t have control over–but that simply means we either don’t understand them or don’t want to bother doing the detective work to figure out what combination of factors led to the particular effect. For example, a couple of years ago a car I was riding in lost traction on a highway and spun out of its driver’s control. The car didn’t crash into another car, or a tree, or even a divider or a barrier. Some may say it’s luck. But us not crashing into anything was simply an outcome of a large number of factors–the ability of the driver to retain basic control, the geometry of the portion of the highway we were on, the cautiousness of other drivers around us. If I had known all those factors and the interplay between them, I would understand why we didn’t crash into anything. Of course, such an understanding would be prohibitively costly to gain, so most of us give up and accept things happening to us in life due to luck.

Interestingly, one man’s chance is simply another man’s logic. Most physicists, for example, pride themselves on the deep understanding of the world around them. They can reduce events to combinations of factors, and depending on how well they understand the factors, they can make predictions with much greater confidence than other people would. As more information is brought in, and as more rules are understood, chance disappears, at least partially.

I say partially because you can’t get rid of chance entirely. Even physicists come up against things they don’t understand- rules are replaced with quantum probabilities. We can do better, but is it worth it? If I offered you, at an extraordinarily high price, insurance against quantum effects in your life, would you buy it? Similarly, we could spend large amounts of money trying to reduce noise in information-carrying media but it probably wouldn’t be worth it given the needed bandwidth.

If chance is like noise, then instead of trying to eliminate it, we should ensure that what drives our lives is powerful enough to make chance insignificant. Being flexible helps- if your life’s design is robust to noise (an equivalent of error correction), you will worry much less about it. In fact, people who have mastered such designs don’t care about chance at all. They may be seen as lucky, but in reality they are simply not susceptible to the quantum probabilities appearing in their life’s equations.