donderdag 25 augustus 2011

Mathematics in a Blog



I'm experimenting with mathJax, www.mathjax.org. That's a way to write LaTeX formulas in html documents which the reader sees displayed just as they ought to be. Well, that's the theory.

$$
\sqrt{\vphantom{I}} n \bigl(\hat\theta_{\text{MLE}}-\theta_0\bigr)~\Rightarrow ~ \mathcal N\,\bigl(\, 0\,, \mathcal I(\theta_0)^{-1}\bigr)
$$


$$
\Pr(T_E\gg t_E)~=~\prod_{A\subseteq E}\,\,\prod_{s_A\in(0_A,t_A]}\, \Biggl(\prod_{B\subseteq A}\Pr\Bigl(T_{A\setminus B}\gg
s_{A\setminus B}\Bigm|T_A\ge s_A\Bigr)^{(-1)^{|B|}}\Biggr)
$$

So I'ld like to hear from you, dear reader. What do you see? Does it look OK? Did you have to wait a long time?

So, how is it done? The LaTeX formulas are typed in completely standard LaTeX, surrounded by double dollar signs. At top of the html source for this page the following code is included: < script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" >
< /script > (I added a space after each start-angle-bracket, so that the html tags for starting and ending a java script are not recognised as such).

Finally, let me add as images what real LaTeX makes of the two formulas:

dinsdag 23 augustus 2011

The true story of the VvS+OR logo

The logo as we see it on the cover of Statistica Neerlandica was drawn sometime around 1970, freehand, by CWI resident artist Tobias Baanders. Presumably he was inspired by earlier VVS graphic design, which almost always featured a standard normal probability density as the recognisable trade mark of all statisticians. The role of operations research, especially deterministic operations research, is perhaps encapsulated in the left hand part of the logo (associations of optimization, efficiency?). Years later the design was scanned and converted to a postscript file. For a number of years I gave students the exercise: fit a family of smooth curves to the logo, and if possible come up with a statistical (or mathematical) story of the image. However, no one succeeded. Suddenly I had a vision that the logo was a 3-dimensional object viewed in perspective; in fact, it shows nine parallel race tracks receding into the distance on the left hand side; and on the right hand side, we see the race tracks close by, almost from above, as they go over a hill.

Now it was just a question of drawing the curves in three dimensions, in R, and viewing them from a well chosen distance and direction.

The hill on the right hand side is based on a (mirrored) gamma density with shape parameter 7 (my favourite number).



The R code for the “waves” part of this picture can be found here. I use the “rgl” package to create and view a three-dimensional plot. The image is then saved in svg format (scalable vector graphic). 

In three dimensions the notion of a “filled closed path” doesn't make sense. Surfaces are represented in rgl by wire frame or similar piecewise linear objects. I therefore used rgl only to draw the boundaries of the nine strips, as nine closed polygonal paths.

Unfortunately, in the transition via rgl from R to svg, what originally were 9 closed polygonal paths (each with about 500 vertices) are broken up into a large number of smaller not-closed polygonal paths, collected together in one graphical object. In a graphical editor (Adobe Illustrator or Inkscape) I first break up the object into its constituents, then I have the constituents joined into one path. Finally I convert the closed path into a filled closed path (most easily done by a one word replacement in the svg source text file).

In order for this to work it is necessary that the many polygonal line segments can be joined together into a single closed path without adding new line connections, since otherwise extra lines are added, resulting in surprising and pretty but unintended results. I satisfied this criterium by adding a strip perpendicular to the nine strips in the image, connecting the nine strips together. That part of the image is outside of the clipped area to the right.

The final image is composed in Keynote, Apple's presentation editor. This preserves scalable images as scalable images, including characters from fonts. So one can finally export a pdf file consisting entirely of scalable components ... except that at very high resolution one will see that the curves of the nine race-tracks are actually polygonal lines. This needs to be fixed by replacing the polygonal lines by spline curves, which I believe can be easily done in Illustrator or Inkscape, or alternatively in the svg source. The main problem will be to keep the sharp corners at the ends of the strips.

The letters VvS+OR are (mostly) typeset in URW++ Bauhaus 93. Under the name Blippo Black, it was designed by Joe Taylor in 1969, inspired by Herbert Bayer’s 1925 experimental “universal typeface”. Bayer was director of printing and advertising for Walter Gropius’ Bauhaus and in his minimalistic font, lowercase and uppercase letters were scaled versions of one another. The font reminds me of publications from the early days of the VVS (late fourties, Dutch graphic design: modernistic and minimalistic). 

However, the ‘S’ and the ‘R’ come from another font: Neufville Digital Futura. I found the ‘S’ and the ‘R’ of Bauhaus 93 both a little too outspoken, while Futura is a more bland typeface, lending itself well to combination with more outspoken characters.

Futura again goes back to the Bauhaus movement, being designed in 1927 by Paul Renner. From Wikipedia: Futura has an appearance of efficiency and forwardness. The typeface is derived from simple geometric forms (near-perfect circles, triangles and squares)

Luc Devroye of McGill University gave me a lot of good advice on this part of the logo project (though I did not follow all of it!).

The script letters SMS are typeset in Tex Gyre Chorus: an open source version of ITC Zapf Chancery, designed by Hermann Zapf in 1979 and inspired by Italian renaissance papal chancery writing, and included as a system font in Apple's Mac OS.

Both type-faces are built of a bare minimum of simple strips or brush strokes, resembling the waves in the image, yet each with a very distinctive character.

I find the combination of two contrasting type-faces, Bauhaus (Futura) and Chancery, each with historical and cultural connotations, together with the dynamic fluidity of the waves of the logo, rather pleasing. But that’s a matter of taste.