Archive for June, 2007

Richard Rorty

Sunday, June 17th, 2007

I never took one of Richard Rorty’s classes while I was in college, but he seemed to have a lot of influence on many of my friends. Particularly my friends studying the humanities, who seemed to be strongly reaffirmed in their decision to not be techies by his lectures. (And I think at a school like Stanford that kind of reaffirmation is a really good thing…)

I think he may have been somewhat extreme in his view. My friend Mike says he asked him something to the affect of if he really thought math was a social construct, or if he really thought that true in a mathematical sense was the same as some kind of subjective truth and he essentially said “yes, math is no different than poetry.” I haven’t thought about this stuff much but that seems intuitively wrong to me.

This Slate article had a series of interviews with various people about Richard Rorty. Daniel Dennett’s comments are pretty interesting:

I had said that it mattered greatly to me to have the respect of scientists—that it was important to me to explain philosophical issues to scientists in terms they could understand and appreciate. He replied that he didn’t give a damn what scientists thought of his work; he coveted the attention and respect of poets!

It made me think about whose respect I really want :). I’d also have to choose the poets respect, although my life decisions don’t reflect that at all…

I broke gcc!

Friday, June 15th, 2007

I’ve been working way too much lately writing an ugly mix of C++ and Prolog. It’s hard to decide which is a more painful language to work with. Computer languages have definitely improved since the 80s.

Today I wrote some code that crashed gcc:

lukeb@lukeb:~/q/qec/src % g++ -c aa.cc
aa.cc: In member function ‘virtual void powerset::qec::HumanStreamFormatter::format(powerset::qec::DocStream&, powerset::qec::ValueFunctor&)’:
aa.cc:64785: internal compiler error: Bus error
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for instructions.

I’ve been using gcc for so many years and it never crashed before so at first it was kind of exciting. But then I was completely stuck.

Luckily my coworker Yingwei had worked on the intel compiler for many years and helped me debug it. Turned out I was passing a class by reference but had forgotten to include its definition in the header file. I’m not completely sure why gcc didn’t just give an error…

Naive Sort

Thursday, June 7th, 2007

I’ve been learning some Prolog recently since at my work there is a large amount of linguistics processing written in it. I was reluctant at first, but it’s kind of opening my mind to a new way of thinking.

I was looking for a sorting function in Prolog and several websites mention what they call “naive” sort. You might think it’s bubble sort, but in fact it’s this:

naive_sort(List,Sorted):-perm(List,Sorted),is_sorted(Sorted).

is_sorted([]).
is_sorted)[_]).
is_sorted([X,Y|T]):-X=<Y,is_sorted([Y|T]).

Generate every permutation and check if it’s sorted. Wow. That is truly a naive sort.

Random fun math from years ago

Tuesday, June 5th, 2007

An agent taking random walk on a line where he moves one unit left or right in each step returns back to where he started in finite time with probability one. Think about that — it’s not obvious. One way to prove it is to show that the expected time it takes to return where it started is finite.

An agent taking the same kind random walk in two dimensions (where he can go one unit North South East or West) also returns to the origin with probability one. But in three dimensions it only returns with probability around 0.34. In four or more dimensions apparently there’s no known closed form solution for the probability.

I was playing with R a little and I made a graph of what percent of walks converge to the origin over time:

Check out how easy it is to write this kind of thing:


# Returns an estimate of the percent of random walks on a grid returning to the origin
# - samples the number of samples to use
# - iters the number of iterations to try
# - dim the number of dimensions

return.to.origin = function(samples=1000, iters=10000, dim=1) {
pct.returned = rep(0, iters)
returned = rep(FALSE, samples)
loc = matrix(data=0, nrow=samples, ncol=dim)
for(i in 1:iters) {
loc = loc + sample(c(-1,1), samples*dim, replace=TRUE)
returned = returned | apply(loc == 0, 1, min )
pct.returned[i] = mean(returned)
}
return(pct.returned)
}