Cover image for Introduction to scientific programming and simulation using R
Title:
Introduction to scientific programming and simulation using R
Personal Author:
Publication Information:
Boca Raton, FL : Chapman & Hall/CRC, 2009.
Physical Description:
xix, 453 p. : ill. ; 24 cm.
ISBN:
9781420068726
General Note:
"This volume is not about the application of statistical techniques, but rather shows how to turn algorithms into code"--Back cover.

Available:*

Library
Item Barcode
Call Number
Material Type
Item Category 1
Status
Searching...
30000010235754 Q183.9 J66 2009 Open Access Book Book
Searching...

On Order

Summary

Summary

Known for its versatility, the free programming language R is widely used for statistical computing and graphics, but is also a fully functional programming language well suited to scientific programming.

An Introduction to Scientific Programming and Simulation Using Rteaches the skills needed to perform scientific programming while also introducing stochastic modelling. Stochastic modelling in particular, and mathematical modelling in general, are intimately linked to scientific programming because the numerical techniques of scientific programming enable the practical application of mathematical models to real-world problems.

Following a natural progression that assumes no prior knowledge of programming or probability, the book is organised into four main sections:

Programming In Rstarts with how to obtain and install R (for Windows, MacOS, and Unix platforms), then tackles basic calculations and program flow, before progressing to function based programming, data structures, graphics, and object-oriented code A Primer on Numerical Mathematicsintroduces concepts of numerical accuracy and program efficiency in the context of root-finding, integration, and optimization A Self-contained Introduction to Probability Theorytakes readers as far as the Weak Law of Large Numbers and the Central Limit Theorem, equipping them for point and interval estimation Simulation teaches how to generate univariate random variables, do Monte-Carlo integration, and variance reduction techniques

In the last section, stochastic modelling is introduced using extensive case studies on epidemics, inventory management, and plant dispersal. A tried and tested pedagogic approach is employed throughout, with numerous examples, exercises, and a suite of practice projects. Unlike most guides to R, this volume is not about the application of statistical techniques, but rather shows how to turn algorithms into code. It is for those who want to make tools, not just use them.


Reviews 1

Choice Review

This book by Jones, Maillardet, and Robinson (all, mathematics and statistics, Univ. of Melbourne, Australia) is an introduction to programming in R. R is an open source software package that is widely used in statistical analysis. Unlike most other works on R, this book begins by discussing R as a programming language, rather than by using R to perform various kinds of statistical analysis. The second section of the book discusses numerical methods including root finding, integration, and optimization. These first two sections are accessible to lower-level undergraduates with little background in statistics. The volume's third and fourth sections build on the first two sections to introduce the reader to probability, statistics, and Monte Carlo simulation. This work will be of interest to instructors teaching courses in programming to statistics students as well as to users of R who want to learn R programming. Compare this book with P. Dalgaard's Introductory Statistics with R (1st ed., 2002; 2nd ed., 2008), which provides more coverage of the statistical procedures built into R, but does not cover R programming as thoroughly. Summing Up: Recommended. Academic audiences, lower-division undergraduate and above, and professionals/practitioners. B. Borchers New Mexico Institute of Mining and Technology


Table of Contents

Prefacep. v
I Programmingp. 1
1 Setting upp. 3
1.1 Installing Rp. 3
1.2 Starting Rp. 3
1.3 Working directoryp. 4
1.4 Writing scriptsp. 5
1.5 Helpp. 5
1.6 Supporting materialp. 5
2 R as a calculating environmentp. 11
2.1 Arithmeticp. 11
2.2 Variablesp. 12
2.3 Functionsp. 13
2.4 Vectorsp. 15
2.5 Missing datap. 18
2.6 Expressions and assignmentsp. 19
2.7 Logical expressionsp. 20
2.8 Matricesp. 23
2.9 The workspacep. 25
2.10 Exercisesp. 25
3 Basic programmingp. 29
3.1 Introductionp. 29
3.2 Branching with ifp. 31
3.3 Looping with forp. 33
3.4 Looping with whilep. 36
3.5 Vector-based programmingp. 38
3.6 Program flowp. 39
3.7 Basic debuggingp. 41
3.8 Good programming habitsp. 42
3.9 Exercisesp. 43
4 I/O: Input and Outputp. 49
4.1 Textp. 49
4.2 Input from a filep. 51
4.3 Input from the keyboardp. 53
4.4 Output to a filep. 55
4.5 Plottingp. 56
4.6 Exercisesp. 58
5 Programming with functionsp. 63
5.1 Functionsp. 63
5.2 Scope and its consequencesp. 68
5.3 Optional arguments and default valuesp. 70
5.4 Vector-based programming using functionsp. 70
5.5 Recursive programmingp. 74
5.6 Debugging functionsp. 76
5.7 Exercisesp. 78
6 Sophisticated data structuresp. 85
6.1 Factorsp. 85
6.2 Dataframesp. 88
6.3 Listsp. 94
6.4 The apply familyp. 98
6.5 Exercisesp. 105
7 Better graphicsp. 109
7.1 Introductionp. 109
7.2 Graphics parameters: parp. 111
7.3 Graphical augmentationp. 113
7.4 Mathematical typesettingp. 114
7.5 Permanencep. 118
7.6 Grouped graphs: latticep. 119
7.7 3D-plotsp. 123
7.8 Exercisesp. 124
8 Pointers to further programming techniquesp. 127
8.1 Packagesp. 127
8.2 Frames and environmentsp. 132
8.3 Debugging againp. 134
8.4 Object-oriented programming: S3p. 137
8.5 Object-oriented programming: S4p. 141
8.6 Compiled codep. 144
8.7 Further readingp. 146
8.8 Exercisesp. 146
II Numerical techniquesp. 149
9 Numerical accuracy and program efficiencyp. 151
9.1 Machine representation of numbersp. 151
9.2 Significant digitsp. 154
9.3 Timep. 156
9.4 Loops versus vectorsp. 158
9.5 Memoryp. 160
9.6 Caveatp. 161
9.7 Exercisesp. 162
10 Root-findingp. 167
10.1 Introductionp. 167
10.2 Fixed-point iterationp. 168
10.3 The Newton-Raphson methodp. 173
10.4 The secant methodp. 176
10.5 The bisection methodp. 178
10.6 Exercisesp. 181
11 Numerical integrationp. 187
11.1 Trapezoidal rulep. 187
11.2 Simpson's rulep. 189
11.3 Adaptive quadraturep. 194
11.4 Exercisesp. 198
12 Optimisationp. 201
12.1 Newton's method for optimisationp. 202
12.2 The golden-section methodp. 204
12.3 Multivariate optimisationp. 207
12.4 Steepest ascentp. 209
12.5 Newton's method in higher dimensionsp. 213
12.6 Optimisation in R and the wider worldp. 218
12.7 A curve fitting examplep. 219
12.8 Exercisesp. 220
III Probability and statisticsp. 225
13 Probabilityp. 227
13.1 The probability axiomsp. 227
13.2 Conditional probabilityp. 230
13.3 Independencep. 232
13.4 The Law of Total Probabilityp. 233
13.5 Bayes' theoremp. 234
13.6 Exercisesp. 235
14 Random variablesp. 241
14.1 Definition and distribution functionp. 241
14.2 Discrete and continuous random variablesp. 242
14.3 Empirical cdf's and histogramsp. 245
14.4 Expectation and finite approximationsp. 246
14.5 Transformationsp. 251
14.6 Variance and standard deviationp. 256
14.7 The Weak Law of Large Numbersp. 257
14.8 Exercisesp. 261
15 Discrete random variablesp. 267
15.1 Discrete random variables in Rp. 267
15.2 Bernoulli distributionp. 268
15.3 Binomial distributionp. 268
15.4 Geometric distributionp. 270
15.5 Negative binomial distributionp. 273
15.6 Poisson distributionp. 274
15.7 Exercisesp. 277
16 Continuous random variablesp. 281
16.1 Continuous random variables in Rp. 281
16.2 Uniform distributionp. 282
16.3 Lifetime models: exponential and Weibullp. 282
16.4 The Poisson process and the gamma distributionp. 287
16.5 Sampling distributions: normal, X2, and tp. 292
16.6 Exercisesp. 297
17 Parameter Estimationp. 303
17.1 Point Estimationp. 303
17.2 The Central Limit Theoremp. 309
17.3 Confidence intervalsp. 314
17.4 Monte-Carlo confidence intervalsp. 321
17.5 Exercisesp. 322
IV Simulationp. 329
18 Simulationp. 331
18.1 Simulating iid uniform samplesp. 331
18.2 Simulating discrete random variablesp. 333
18.3 Inversion method for continuous rvp. 338
18.4 Rejection method for continuous rvp. 339
18.5 Simulating normalsp. 345
18.6 Exercisesp. 348
19 Monte-Carlo integrationp. 355
19.1 Hit-and-miss methodp. 355
19.2 (Improved) Monte-Carlo integrationp. 358
19.3 Exercisesp. 360
20 Variance reductionp. 363
20.1 Antithetic samplingp. 363
20.2 Importance samplingp. 367
20.3 Control variatesp. 372
20.4 Exercisesp. 374
21 Case studiesp. 377
21.1 Introductionp. 377
21.2 Epidemicsp. 378
21.3 Inventoryp. 390
21.4 Seed dispersalp. 405
22 Student projectsp. 421
22.1 The level of a damp. 421
22.2 Roulettep. 425
22.3 Buffon's needle and crossp. 428
22.4 Insurance riskp. 430
22.5 Squashp. 433
22.6 Stock pricesp. 438
Glossary of R commandsp. 441
Programs and functions developed in the textp. 447
Indexp. 449