Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Simulation for Data Science with R

You're reading from   Simulation for Data Science with R Effective Data-driven Decision Making

Arrow left icon
Product type Paperback
Published in Jun 2016
Publisher Packt
ISBN-13 9781785881169
Length 398 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Matthias Templ Matthias Templ
Author Profile Icon Matthias Templ
Matthias Templ
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Introduction 2. R and High-Performance Computing FREE CHAPTER 3. The Discrepancy between Pencil-Driven Theory and Data-Driven Computational Solutions 4. Simulation of Random Numbers 5. Monte Carlo Methods for Optimization Problems 6. Probability Theory Shown by Simulation 7. Resampling Methods 8. Applications of Resampling Methods and Monte Carlo Tests 9. The EM Algorithm 10. Simulation with Complex Data 11. System Dynamics and Agent-Based Models Index

High performance computing

Initially, it is important to measure which lines of code take the most computation time. Here, you should try to solve problems with the processing time of individual calculations by improving the computation time. This can often be done in R by vectorization, or often better by writing individual pieces of code in a compilable language, such as C, C++*, or Fortran**.

In addition, some calculations can be parallelized and accelerated through parallel computing.

Profiling to detect computationally slow functions in code

Take an example where you have written code for your data analysis but it runs (too) slow. However, it is most likely that not all your lines of code are slow and only a few lines need improvement in terms of computational time. In this instance it is very important to know exactly what step in the code takes the most computation time.

The easiest way is to find this out is to work with the R function system.time. We will compare two models:

data(Cars93...
You have been reading a chapter from
Simulation for Data Science with R
Published in: Jun 2016
Publisher: Packt
ISBN-13: 9781785881169
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime