Book Image

R Object-oriented Programming

By : Kelly Black
Book Image

R Object-oriented Programming

By: Kelly Black

Overview of this book

Table of Contents (19 chapters)
R Object-oriented Programming
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
4
Calculating Probabilities and Random Numbers
Package Management
Index

Chapter 11. Case Study – Simulation

We will now examine a set of S3 classes designed to implement a Monte-Carlo simulation. The example scripts include a class to generate a single simulation as well as a class to run and collect the results from multiple simulations. The simulation class includes two derived classes. One is used for simulations of a discrete stochastic process, and the other is for simulations of a stochastic differential equation.

This section is roughly divided into the following parts:

  • The simulation classes

  • The Monte-Carlo class

  • Examples

We will first examine a set of simulation classes that are designed to generate a single simulation of a stochastic system. The classes make use of a base class to manage the parameters. Two classes are derived from the base class. The first derived class is used to simulate a discrete stochastic system. The second derived class is used to approximate a stochastic differential equation.

After examining the simulation classes, a master class...