Blog

Ein literarisches Portrait Bernhard von Lepels?

Bernhard von Lepel ist für uns hauptsächlich interessant durch seine Freundschaft mit Theodor Fontane, und das meiste, das wir über ihn wissen, wissen wir durch Fontane. Fontane hat dem Freund ein langes Kapitel in seinen Jugenderinnerungen (Kapitel 8 von “Der Tunnel über der Spree” in “Von 20 bis 30”) gewidmet, und ihn auch sonst gelegentlich beschrieben — seltsamerweise zum Teil verfremdet (z.B. als der “Italienenthusiast” in der etwas mysteriösen Skizze “Cafés von heut und Konditoreien von ehmals” von 1886). Dennoch bleibt Lepel’s Persönlichkeit überraschend undeutlich.

An Intuitive Explanation for the Birthday Paradox

The so-called “birthday paradox” concerns the fact that even in surprisingly small groups the probability for at least two people to share their birthdate is surprisingly high.

The combinatorics of the Birthday Paradox are not hard; in fact, it is a standard example in introductory textbooks. Yet, the typical exact treatment provides no intuitive sense for the way the probability depends on the size of the sample and the population.

Here is an approximate solution that shows that the probability in question is, in fact, a Gaussian.

Go is Weird: Strings

Having done extensive programming in C, I am not particularly spoiled when it comes to idiosyncrasies of a language’s “string” type. Yet, Go’s string types keeps tripping me up — why does it all still have to be that complicated?

Understanding Go's context Package

Go request handlers typically include a “context” value as their first argument:

func handler( ctx context.Context, ... ) { 
    ...
}

In my experience, this convention is typically fastidiously followed, but then nothing is ever done with that ctx argument. What is it really for? Unfortunately, the description in the official Go package documentation is a bit cryptic, and the type implementation itself does not reveal anything either (the default context is just an empty struct).

Properly understood, it’s actually a really convenient idiom; however, its value is not so much in the context package itself, but in some idioms in the code that use the package.

Computing the Normal Distribution Function

Every once in a while, I need to evaluate the normal distribution function $\Phi(x)$:

$$ \Phi(x) = \frac{1}{\sqrt{2 \pi}} \int_{-\infty}^x \! e^{-\frac{1}{2}t^2} \, dt $$

Unfortunately, it is not always available in the standard math libraries, and hence I have to implement a “good-enough” version myself. Here are some options.

Better Highlighting for the Emacs Region

The default highlighting of the Emacs “region” (the part of a buffer between “point” and “mark” — selected text, if any, in other words) is, out of the box, barely visible, at least against a light background. An attempt to customize it runs into an interesting problem when used in a text- or terminal-based environment, rather than a GUI.