Archive for LaTeX

spot the LaTeX mistake

Posted in Books, Linux with tags , on April 22, 2013 by xi'an

It took me forever to spot the (obvious) mistake in the following LaTeX formula


\int \exp\[ -\{ (n+\sigma^{-2})\mu^2 -2n\mu{\bar x_n} + n ({\bar x_n})^2 \}/2 \]

Can you find it?!

one of those weird LaTeX incidents…

Posted in Books, University life with tags , , , on February 26, 2013 by xi'an

This afternoon, I had to recompile a LαTεX file written two years ago (in French) and it returned the error:

 Missing \endcsname inserted.
<to be read again>
                   \unskip
l.182 \citeyear{berger:robert:1990}
                                    avec James Berger dans un article aux {\...

and I couldn’t figure out what had changed into the compiler to produce this strange message… Except that removing the line

\usepackage[french]{babel}

was removing the error message (but producing garbage French!).

I thus checked on forums and found some solution on a French LαTεX users forum called MathemaTeX. The issue had to do with using `:’ in my reference codes… However, after fiddling with this solution, I ended up with

\usepackage[french,english]{babel}

as enough to remove the error message and produce the same output as earlier. Weird! (As I always use the same bibTeX file and do use babel-french from time to time… Maybe not that often with citations, actually!)

\verbatim [beamer package]

Posted in R, Statistics, University life with tags , , , , , , on June 12, 2012 by xi'an

Once again working on my slides for the AMSI Lecture 2012 tour, it took me a while to get the following LaTeX code (about the family reunion puzzle) to work:

\begin{frame}[fragile,label=notleM2]
\slidetitle{A family meeting}
\begin{block}{Random switch of couples}
\only<1>{
\begin{itemize}
\item Pick two couples [among the 20 couples] at random with probabilities proportional
to the number of other couples they have not seen\\
{\verb+prob=apply(meet(T)==0,1,sum)+}
\item switch their respective position during one of the 6 courses
\item accept the switch with Metropolis--Hsatings probability\\
{\verb#log(runif(1))<(penalty(old)-penalty(new))/gamma#}
\end{itemize}
}
\only<2>{
\begin{verbatim}
for (t in 1:N){
  prop=sample(1:20,2,prob=apply(meet(T)==0,1,sum))
  cour=sample(1:6,1)
  Tp=T
  Tp[prop[1],cour]=T[prop[2],cour]
  Tp[prop[2],cour]=T[prop[1],cour]
  penatp=penalty(meet(Tp))
  if (log(runif(1))<(penat-penatp)/gamma){
    T=Tp
    penat=penatp}
  }
\end{verbatim}
}
\end{block}
\end{frame}

since I was getting error messages of the form

[86] (./simulation.38.vrb) [87] (./simulation.39.vrb
!Illegal parameter number in definition of \beamer@doifinframe.
                 l
l.12 }
?

Using two frames in a row instead of the “only<2>” version  did not help…
Read more »

\STATE [algorithmic package]

Posted in Books, Kids, pictures, R, Statistics, Travel, University life with tags , , , , , , , , , on June 8, 2012 by xi'an

I fought with my LαTεX compiler this morning as it did not want to deal with my code:

 \begin{algorithmic}[1]
 \STATE N=1000
 \STATE $\hat\pi=0$
 \FOR {I=1,N}
 \STATE X=RDN(1), Y=RDN(1)
 \IF {$\text{X}^2+\text{Y}^2<1$}
 $\hat\pi$ = $\hat\pi +1$
 \ENDIF
 \ENDFOR
 \RETURN 4*$\hat\pi/$N
 \end{algorithmic}
 

looking on forums for incompatibilities between beamer and algorithmic, and adding all kinds of packages, to no avail. Until I realised one \STATE was missing:

 \begin{algorithmic}[1]
 \STATE N=1000
 \STATE $\hat\pi=0$
 \FOR {I=1,N}
 \STATE X=RDN(1), Y=RDN(1)
 \IF {$\text{X}^2+\text{Y}^2<1$}
 \STATE $\hat\pi$ = $\hat\pi +1$
 \ENDIF
 \ENDFOR
 \RETURN 4*$\hat\pi/$N
 \end{algorithmic}
 

(This is connected with my AMSI public lecture on simulation, obviously!)

the universe in zero words

Posted in Books, Kids, Statistics, University life with tags , , , , , , , , , , , , , , , , on May 30, 2012 by xi'an

The universe in zero words: The story of mathematics as told through equations is a book with a very nice cover: in case you cannot see the details on the picture, what looks like stars on a bright night sky are actually equations discussed in the book (plus actual stars!)…

The universe in zero words is written by Dana Mackenzie (check his website!) and published by Princeton University Press. (I received it in the mail from John Wiley for review, prior to its publication on May 16, nice!) It reads well and quick: I took it with me in the métro one morning and was half-way through it the same evening, as the universe in zero words remains on the light side, esp. for readers with a high-school training in math. The book strongly reminded me (at times) of my high school years and of my fascination for Cardano’s formula and the non-Euclidean geometries. I was also reminded of studying quaternions for a short while as an undergraduate by the (arguably superfluous) chapter on Hamilton. So a pleasant if unsurprising read, with a writing style that is not always at its best, esp. after reading Bill Bryson’s “Seeing Further: The Story of Science, Discovery, and the Genius of the Royal Society“, and a book unlikely to bring major epiphanies to the mathematically inclined. If well-documented, free of typos, and engaging into some mathematical details (accepting to go against the folk rule that “For every equation you put in, you will lose half of your audience.” already mentioned in Diaconis and Graham’s book). With alas a fundamental omission: no trace is found therein of Bayes’ formula! (The very opposite of Bryson’s introduction, who could have arguably stayed away from it.) The closest connection with statistics is the final chapter on the Black-Scholes equation, which does not say much about probability…. It is of course the major difficulty with the exercise of picking 24 equations out of the history of maths and physics that some major and influential equations had to be set aside… Maybe the error was in covering (or trying to cover) formulas from physics as well as from maths. Now, rather paradoxically (?) I learned more from the physics chapters: for instance, the chapters on Maxwell’s, Einstein’s, and Dirac’s formulae are very well done. The chapter on the fundamental theorem of calculus is also appreciable.

Read more »

Follow

Get every new post delivered to your Inbox.

Join 358 other followers