C++ Design: Good or Bad?

Reminiscent of a previous life: John D. Cook has a post up on two perspectives of the design of C++.

As I stated in the comments over there, I think C++ is useful for a lot of things (and I still like using it), but you should just use the language that you think is best suited for the task.


Spring Break

Spring break is here, so it will be a good time to take a look at a couple things in addition to getting some work done.

Here’s a couple things I’m looking at right now:

As for work, among many other things, I’m trying to find a good “how-to” on deriving a curvature tensor. It seems that differential geometers like to leave these things as an “exercise.”

Pi Day

I forgot to think of anything intelligent to write about for WoBloMo, so you get this post specifically designed to hit the deadline.

You’ll notice that the post date doesn’t have an odd day. WordPress doesn’t flip for DST, so rather than bother with switching it manually (come on, WP, really?), I just leave it at the default, which is GMT. That means that this post will have a date of March 14th, which is Pi Day! But it’s still the 13th where I am, so I will meet the requirement.

Happy Pi Day!

Visualizing Hyperspheres

Since all you in the blogosphere seem to love hyperspheres so much, here’s a link to someone who put together some visualizations of hyperspheres and polytopes in 4 dimensions:


The approach is pretty cool, and some of the images are quite stunning.

Barbara Liskov Wins Turing

Via Suresh.

I have only a couple things to say on the topic, since her area of expertise is different than the area that I’m studying:

  1. Data abstraction, modules, and binding are extremely important to get modern software working easily. If it weren’t for pioneers like her, we would be taking a lot longer to do the tasks that we do every day. Our lives would simply not be the same.

    I’m sure that Google appreciates her work on distributed computing too. :-)

  2. I long for the day when it’s not notable that women (as opposed to men) win the Turing as well. I hope it becomes as archaic as saying “a woman was accepted to a university.”

Reasoning in Higher Dimensions: Measure

In a previous post on this topic, I said that hyperspheres get a bad rap. They’re doing their best to be perfectly round, and someone comes along and accuses them of being inadequate, or weird. It turns out that hyperspheres aren’t really weird at all. It’s measure that’s weird. And where measure is concerned, there are objects out there that truly display that weirdness.

To recap, I was talking about how the volume of a unit hypersphere measured the normal way (with its radius = 1) approaches zero with increasing dimension. I also mentioned that even though a “unit” hypercube that circumscribes the unit sphere (i.e., a hypercube with inradius = 1) has volume that increases exponentially with the dimension (2d), a hypercube with circumradius = 1 decreases even faster than the volume of the hypersphere. Why is one configuration different than the other?

The answer is that they’re not different. A cube is a cube, no matter how you orient it. If its side is of length s, then its volume is sd. What’s different here is our notion of unit measure. We commonly define a unit of volume as the volume of a hypercube with sides of unit length. In that light, it’s not terribly surprising what we know about the volume of hypercubes. So why can’t we just define the unit hypersphere to have unit volume?

This seems objectionable until you realize that we do this all the time in the real world. What’s a gallon? It has nothing to do with an inch or foot. So why do we worry ourselves over defining volume in terms of one-dimensional units? The metric system doesn’t even adhere to this standard. A liter is a cubic decimeter. Why? It just worked out that way. Since these units are all just arbitrary, we could just declare that unit volume is the volume of a unit hypersphere. Or not. So a hypersphere’s volume really isn’t that weird. What seems weird is the discrepancy between the geometries of the hypercube and hypersphere.

Are there objects that do act strangely in higher dimensions? Definitely. Consider a multivariate normal distribution (a Gaussian distribution in multiple dimensions). For the sake of simplicity, I’ll consider one with zero mean and variance σ2:

p(x) = \frac 1 {(2\pi)^{n/2}\sigma^n} \exp\left(\frac{\|x\|^2}{2\sigma^2}\right)

Multivariate Gaussians are all nice and round. What can we say about what the distance from the mean (0) looks like? Well, this is just the variance:

\mathbf{E}\|X\|^2 = \mathbf{E}(X_1^2 + \dots + X_n^2) = n\sigma^2

How much does it deviate from this value? We can apply a Chernoff bound (don’t ask me how; deriving Chernoff bounds is not my strong suit):

\mathbf{P}(\left|\|X\|^2 - n\sigma^2\right| > \epsilon n\sigma^2) \leq \exp\left(-\frac{n\epsilon^2}{24}\right)

Let’s take another look at this bound, though. It’s saying that the probability of the squared distance from the mean deviating from nσ2 by more than a small percentage decreases exponentially with n. So the points that follow the distribution mostly sit in a thin shell around the mean. But the density function still says that the density is highest at the mean. Now that’s weird.

Why does this happen, though? It’s difficult to get a handle on, but the word “density” is what you have to pay attention to. That shell has an incredibly high volume at higher dimensions (it grows with drd-1). High enough that the density is still lower at the shell than at the mean. Why it’s highest in the shell is even more difficult to figure out. I don’t have a good answer, but I suspect that it has something to do with the fact that the distribution must add up to one, and it has to “fill” all the nooks, and it can’t do that at the mean. It has to do this out in this thin shell.

[Update: I guessed last night that if I multiply the p.d.f. by the boundary volume (i.e. “surface area”) of a hypersphere of radius ||x||, then I should see spikes out at σ√n. I was correct. Below, Micheal Lugo confirmed that intuition slightly more rigorously in the comments. He’s a probabilist, so I think I’m safe. :-) ]

There are certainly weird things that happen in higher dimensions. In my opinion, all these things have more to do with measure than geometry.

Grad Visit Weekend

I promise that I’ll get to the point that I was making earlier this week. But not yet.

The grad visit was this weekend, and even though I’m settled on where I’m going, it was a good way to see what everyone was working on.

It also gave me a chance to go on a hike up to Ensign peak, which is I hike that I hadn’t done before today. The weather was gorgeous despite being cool. The mud on the trail made it interesting, but the fact that I made a couple friends made up for it. If you visit Salt Lake, you should do that hike. It’s an excellent way to take the city in.