Statistical Computing in C++ and R (Hardback) book cover

Statistical Computing in C++ and R

By Randall L. Eubank, Ana Kupresanin

© 2011 – Chapman and Hall/CRC

556 pages | 28 B/W Illus.

Purchasing Options:$ = USD
Hardback: 9781420066500
pub: 2011-12-01
eBook (VitalSource) : 9781439893937
pub: 2012-01-31
from $44.95

FREE Standard Shipping!
e–Inspection Copy


With the advancement of statistical methodology inextricably linked to the use of computers, new methodological ideas must be translated into usable code and then numerically evaluated relative to competing procedures. In response to this, Statistical Computing in C++ and R concentrates on the writing of code rather than the development and study of numerical algorithms per se. The book discusses code development in C++ and R and the use of these symbiotic languages in unison. It emphasizes that each offers distinct features that, when used in tandem, can take code writing beyond what can be obtained from either language alone.

The text begins with some basics of object-oriented languages, followed by a "boot-camp" on the use of C++ and R. The authors then discuss code development for the solution of specific computational problems that are relevant to statistics including optimization, numerical linear algebra, and random number generation. Later chapters introduce abstract data structures (ADTs) and parallel computing concepts. The appendices cover R and UNIX Shell programming.


  • Includes numerous student exercises ranging from elementary to challenging
  • Integrates both C++ and R for the solution of statistical computing problems
  • Uses C++ code in R and R functions in C++ programs
  • Provides downloadable programs, available from the authors’ website

The translation of a mathematical problem into its computational analog (or analogs) is a skill that must be learned, like any other, by actively solving relevant problems. The text reveals the basic principles of algorithmic thinking essential to the modern statistician as well as the fundamental skill of communicating with a computer through the use of the computer languages C++ and R. The book lays the foundation for original code development in a research environment.


"…the first treatment of parallel programming in R that I have seen in a book. The text is replete with code examples and there are numerous end-of-chapter exercises."

International Statistical Review, 2013

Table of Contents


Programming paradigms

Object-oriented programming

What lies ahead

Computer representation of numbers


Storage in C++


Floating-point representation


Computing a sample variance

Storage in R


A sketch of C++


Variables and scope

Arithmetic and logical operators

Control structures

Using arrays and pointers


Classes, objects and methods

Miscellaneous topics

Matrix and vector classes

.Input, output and templates

.Function templates


Generation of pseudo-random numbers


Congruential methods

Lehmer type generators in C++

An FMclass

Other generation methods

Nonuniform generation

Generating random normals

Generating random numbers in R

Using the R Standalone Math Library


Programming in R


File input and output

Classes, methods and namespaces

Writing R functions

Avoiding loops in R

An example

Using C/C++ code in R


Creating classes and methods in R


Creating a new class

Generic methods

An example


Numerical linear algebra


Solving linear equations

Eigenvalues and eigenvectors

Singular value decomposition

Least squares

The Template Numerical Toolkit


Numerical optimization


Function objects

Golden section

Newton’s method

Maximum likelihood

Random search


Abstract data structures


ADT dictionary

ADT priority queue

ADT ordered set

Pointer arithmetic, iterators and templates


Data structures in C++


Container basics

Vector and deque

The C++ list container


The map and set containers

Algorithm basics


Parallel computing in C++ and R



Basic MPI commands for C++

Parallel processing in R

Parallel random number generation


A An introduction to Unix

A.Getting around and finding things

A.Seeing what’s there

A.Creating and destroying things

A.Things that are running and how to stop them

B An introduction to R

B.R as a calculator

B.R as a graphics engine

B.R for statistical analysis

C C++ library extensions (TR)

C.Pseudo-random numbers

C.Hash tables


D The Matrix and Vector classes

E The ranGen class



About the Series

Chapman & Hall/CRC The R Series

Learn more…

Subject Categories

BISAC Subject Codes/Headings:
COMPUTERS / Machine Theory
MATHEMATICS / Probability & Statistics / General