Monthly Archives: May 2012

Author-year bibliographies in LaTeX

For submission to some conferences and journals, you can’t use BibTeX, as they may want one single (La)TeX file containing everything: the text of the article, and the bibliography, for easy typesetting and inclusion in the proceedings. Standard LaTeX use produces a numbered bibliography. Here is a mini file which includes two citations:

\documentclass{article}

\begin{document}

This is a test of the bibliography system of \LaTeX.   It cites
two works.  Ant \& Bee~\cite{adam15} investigate how insects
can annoy humans, while another work~\cite{rhin20} investigates 
how big animals can annoy humans.

\begin{thebibliography}{9}
\bibitem{adam15}Ant, A. \& Bee, B. (2015). The busy ant and
   bee guide to being a nuisance, \emph{Human-Insect Interaction},
   100(1), 1--1000

\bibitem{rhin20}Rhino, R. \& Elephant, E. (2020). \emph{Theory
   and Practice of Ruining Big Game Expeditions}, Safari Press
\end{thebibliography}
\end{document}

which typesets to produce

Note that each bibitem contains two fields: a “key” (in braces), and the publication details. This method of citation and referencing is fine for many scientific documents, and many journals and conferences. However, some conferences prefer their citations to be in “author year” style, similar to that prescribed by the APA.

This can be easily obtained by using the natbib style, which provides a new implementation of the standard LaTeX cite command. Here is the above article again:

\documentclass[a4paper]{article}
\usepackage{natbib}

\begin{document}

This is a test of the \texttt{natbib} author-year system.  It cites
two works.  \citet{adam15} investigate how insects can annoy humans,
while another work~\citep{rhin20} investigates how big animals can
annoy humans.

\begin{thebibliography}{}
\bibitem[Ant \& Bee(2015)]{adam15}Ant, A. \& Bee, B. (2015). The
  busy ant and bee guide to being a nuisance, \emph{Human-Insect
  Interaction}, 100(1), 1--1000

\bibitem[Rhino \& Elephant(2020)]{rhin20}Rhino, R. \& Elephant, E.
  (2020). \emph{Theory and Practice of Ruining Big Game
  Expeditions}, Safari Press
\end{thebibliography}
\end{document}

Note that here the bibitem entries have three fields:

\bibitem[authors(year)]{key}publication details

and there are two versions of cite. Actually there are many more; see the natbib documentation for details. Or have a look at this page for a summary. The command citet produces “Authors (Year)” in the text, whereas citep produces “(Author, Year)”. This is why the first field in a bibitem must be of the form [Author(Year)] so that the natbib parser can separate the authors and the year, and typeset the citation accordingly.

And the result is:

This is all very simple and straightforward, but for some reason I found it very hard to find all this information in one place.

A piecewise polynomial approximation to the normal CDF

The normal cumulative distribution function

\displaystyle{\Phi(z)=\frac{1}{\sqrt{\pi}}\int^z_{-\infty}e^{-x^2}\;dx}

has the unfortunate property of not being expressible in terms of elementary functions; that is, it can’t be computed with functions available on a standard scientific calculator. Some modern calculators, such as the Casio ClassPad and the TI-Nspire (and some of their predecessors) can indeed evaluate this function, but for students without such calculators, they need to look up tables – surely an old-fashioned method!

To overcome this there have been masses of approximations produced over the years; one of the simplest is the logistic approximation:

\displaystyle{\Phi(z)\approx 1-\frac{1}{1+e^{1.702z}}\mbox{ for }z\ge 0.}

Note that the integrand is an even function, which means that

\Phi(z)=1-\Phi(-z)

if z<0, and so we only have to find an approximation for positive z.

However, there is a conceptually even easier function, which dates back to a 1968 paper by John Hoyt:

\displaystyle{\Phi(z)\approx\left\{\begin{array}{ll}\displaystyle{z\left(\frac{9-z^2}{24}\right)+\frac{1}{2}}&\mbox{if }0\le z\le 1\\[5mm]  \displaystyle{\frac{(z-3)^3}{48}+1}&\mbox{if }z\ge 1\end{array}\right.}

Here is a plot of the two of them together (created using Maxima and gnuplot):

and here is a plot of their difference:

In fact the absolute difference is 0.01 or less for 0\le z<3.78. This piecewise polynomial function provides a nice quick-and-dirty approximation to the normal CDF.