proj3 - Simulation Project This project is a different from...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Simulation Project This project is a different from the other projects, in that I'm giving you choices this time. The programming objective in this lab is to apply what you've learned about loops to solve an involved science or engineering problem. You'll also need to learn how to generate a random number in C++ and use that in this project. I'll describe how to do that on this page. The choice comes into play with the applications. You'll have four choices and I've been working with faculty members in other departments on choosing applications that should interest you. In all cases, you'll need to draw a little bit from background knowledge you have, generally from trig. and physics, but you may find that the projects allow you to view something you are studying in another course from a different light. Each option is designed to be similar in difficulty. Before I give you your options, I'm going to provide some background on simulations and notes on random numbers that you'll be using in your project. Simulations One use of computers in science is that of simulation , that is, using several trials using a mathematical model of a physical phenomenon to study that phenomenon and look for trends. Of course, the quality of the simulation is only as good as the mathematical model, and the model is rarely a perfect picture of reality, but simulation is extremely useful. There are many reasons to use simulations, ranging from the cost-saving and testing reasons (run a computer simulation to test some new product investing time and money into building it) to ethical reasons (test something potentially life-threatening using a computer simulation and don't harm any lives). This kind of technique involves several trials, so loops are a natural control structure for this kind of programming. In addition, there is an element of chance. To introduce that element of chance, we need to generate a random number. C++ (and just about any other programming language) is capable of doing that, and the details will be explained below. This particular kind of simulation with the element of chance is what we call a Monte Carlo simulation. The idea is based on some of the fundamental ideas of probability and sampling theory, namely that the behavior exhibited in several trials will give an approximation of reality (all, of course, dependent on the quality of the mathematical model used). Notes on Random Numbers in C++ Generating random numbers in C++ requires the following headers: #include <cstdlib> // for random number generator #include <ctime> // for time method so we can seed the generator The process of generating a random (well, technically pseudorandom ) number involves three steps:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1. Set a seed for the random number generator. The random number generator really is a complicated
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 02/10/2011.

Page1 / 5

proj3 - Simulation Project This project is a different from...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online