_gcr

gcr's blog

Hi! I'm gcr, a student studying computer vision. I wrote Goggles, a tool for web graffiti, among many other small projects. I mostly work with Python, Racket, Emacs, and node.js.

February 14, 2012 – Exploring Statistics in Racket

Probability is a hard topic for me in part because it's easy to make trivial arithmetic errors and because it's hard to visualize and understand the problem inside my head. It's very easy to wind up solving a subtly but fatally different problem than what the textbook asks for, and while it's easy to check arithmetic errors, it's impossible to check mistakes in my reasoning.

What's a guy to do? One thought is to write a few lines that describe the problem in your favourite programming language to check your result. This lets you model that strange probability question in terms of following simple instructions to get to the final solution, and it's a powerful and natural way of expressing these kinds of ambiguous, wishy-washy problems. Though the following method won't show you the exact answer and certainly can't help you on an exam, it's a great way of double-checking your work.

For example, what if the problem calls for: "Three red and two blue balls are in a bowl. If you take out two red ones, what's the probability that the next ball will be blue?" By using just ordinary math, you can sort of see that it's \(\frac{2}{3}\), but it's often quite hard to justify your reasoning this way.

What if we can test that concretely? Wouldn't it be wonderful if we could write something like this?

def test():
    bowl = ["Red", "Red", "Red", "Blue", "Blue"]
    bowl.remove("Red")
    bowl.remove("Red")
    return probability(draw_one(bowl) == "Blue")

I'll show you how to do exactly this. The conceptual difference between reasoning about the math abstractly versus coding the steps out explicitly feels like pinning jello to a tree vs. wielding a staple gun with precision and power.

Read more…

February 10, 2012 — The Five Stages of Brussels Sprouts

So now you have to eat Brussels sprouts. Whether by force or thanks to a dietary experiment gone horribly wrong, there's no turning back now. You have to shove those green balls of goop down your gullet one way or another. How could you possibly cope? Like most new Brussels-sprout survivors, you might go through the following five stages to learn to deal with this strange new culinary monstrosity:

  1. Denial. "This can't be happening. I'm not eating Brussels sprouts! This isn't right. What possessed me to even try?"
  2. Anger. "Why on earth am I eating Brussels sprouts? Why do I have to deal with this? There are so many better foods I could be eating! Why can't I just eat those?"
  3. Bargaining. "What if I switch to Broccoli instead just for one night? Nothing bad could possibly come of that, right?
  4. Depression. "There certainly can't be anything worse than Brussels sprouts. I'm doomed to eat them as long as I live."
  5. Acceptance. "Well, at least it's not asparagus."

And well gosh, you're eating Brussels sprouts just like that.

I find that any new change can feel a lot like Brussels sprouts. Whether you're first starting college or learning a new programming language or framework, it's often hard to adjust. On the other hand, this opportunity cost is one part of what binds communities together because the initial stomachache separates the "in" crowd from the "out" crowd.

Before you join a community centered around a software product for example, you have to look at it and decide whether it's worth it to jump in. You then have to take that first painful spoonful and either pack your bags or decide to stick around. Once you're entrenched in that community, it's hard to leave because now that you're used to eating Brussels sprouts, switching to Cauliflower seems like a downright daunting task.

This is partly why engineers get so easily opinionated about their favorite technology. Whether you use Vim or Emacs, ruby/rails or Python/Django, PC or Mac, it's easier to justify your love for your chosen path because understanding the alternative means swallowing your pride and a few spoonfuls of Brussels sprouts.

The Five Stages of C++

  1. Denial. "I'm only using it for small projects, I can't see why any sane person would ever enjoy C++. I'll only download the compiler and work through hello world later."
  2. Anger. "Template error messages are confusing! Why couldn't they make it more like C? What was Stroustrup thinking?!"
  3. Bargaining. "What if I switch to Java? It's slower, but at least it doesn't segfault all over the place!" "Maybe we can just use classes and keep things manageable!"
  4. Depression. "I'll never be able to track down those pointer bugs. Our product sucks; we should just rewrite it all over again."
  5. Acceptance. "I accidentally wrote my own library? What am I becoming?"

The Five Stages of Linux

  1. Denial. "I'm only trying out Linux to hack into things!"
  2. Anger. "What do you mean, 'hardware not supported?' Why can't it play Warcraft? Unity is a terrible UI metaphor!"
  3. Bargaining. "OpenSuSE isn't this bad! And red hat is commercially supported! They certainly work far better than this; I should switch to them, or maybe one of the BSDs!"
  4. Depression. "I wish DistCC worked over IPv6 so I could compile my custom kernel faster. Linux sucks."
  5. Acceptance. "Man, it's certainly too late to go back to Windows now… Might as well enjoy my stay."

Investment

Why is it that major leaps up the ladder of abstraction often require a huge time and learning investment before getting used to them? More importantly, why don't people embrace this so readily? Sticking with the "old" way of doing things leaves the door closed and prevents you from seeing new possibilities. It took decades before the printing press gained widespread adoption, but once that happened, it completely usurped written and block-printed type. The telephone took quite some time before it displaced other communication, but we take instant "at-a-button" communication for granted these days. The personal computer and proliferation of the Internet caused similar paradigm shifts, but only to those who embraced them – the rest were unwilling swept up in the inevitable tidal wave.

We engineers often build things that require large investments to learn. What should we do to lower that cost? Is it the user's fault for failing to learn or is it our fault for failing to teach them? Can this cost be lowered or is it an intrinsic fact of any new technology?

February 9, 2012 — What's this? sneakygcr.net is evolving!

Wow! Hey look everybody, I have an Interblag now! Everyone can go from not-looking-at-my-home-page to not-reading-my-blog. What an upgrade!

Only a few interesting posts from now, I'll be the star of Hackernews.

Why do this?

I'm starting a blog because I need the practice. Writing is hard, and writing sanely takes several orders of magnitude more work than the kind of "fire-and-forget" one-off communication I'm used to.

There are too many wonderful ideas trapped inside my head, and it's time to get them out here "on paper".

Big Redesign

Before, the entire text on my webpage had three words: _gcr, a Contact link, and a Github link, all drowning in a sea of orange. That isn't very search-friendly and it also wasn't very interesting. At least this gives me the framework to publish interesting things for you to sink your teeth into. Now I have no excuse to be uninteresting.

This site is technically unusual: it's written and published completely in Org mode with only a small custom CSS style sheet. This makes it super-easy to write my posts in org-mode, publish them, and keep them in source control.

For example, including snippets of source code is as easy as writing:

#+BEGIN_SRC sh
  for i in `seq 1 10`; do
      echo "Hello ${i}"
  done
#+END_SRC

This becomes:

for i in `seq 1 10`; do
    echo "Hello ${i}"
done
Hello 1
Hello 2
Hello 3
Hello 4
Hello 5
Hello 6
Hello 7
Hello 8
Hello 9
Hello 10

By default, org-mode also includes support for MathJax, which means that including inline LaTeX math is a snap.

\[
x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}
\]
\[ x = \frac{-b \pm \sqrt{b^2-4ac}}{2a} \]

I promise I'll try not to bore you with useless math, but having the ability to do so certainly imbues me with this sense of corrupting power felt by all madmen and politicians. It's hard to control.

Enough overhead and shameless pluggery. I have a few interesting posts bristling on my plate just waiting to be written, but they'll have to wait until later.

Last updated on 2012-04-16 21:06:14 MDT