Cincinnati Free Texts
Basic for Applied Prob
Programs in Q(uick)BASIC
for Applied Probability & Stochastic Processes
Revised: February 2, 1996
The programs are available from me (on the disk), or from WWW
(use SAVE AS in Netscape, or similar). How to run BASIC?
Here is a list of currently available program listings for this class. Unless
marked otherwise, programs are
written in QuickBasic and can run under DOS through QBASIC.
Programs contributed by students may have been slightly edited.
- Sample programs to use as starting points in your own projects (for Chapter 1,
except when marked otherwise).
- YAHTZEE.BAS
Counting four of a kind outcomes in the game of Yahtzee.
Also available:
- C code by Ping Kuo
- Pascal code
- Three executable (ZIP-compressed) compiled from virtualy identical
versions
(Time all three C versus Pascal versus BASIC
and see how much performance can be gained from other languages - Slow CPU recommended)
- Simulation of
the same probability by Masha Bowen. (How accurate a simulation answer is?)
- Select random subsets from any set, by N. V. Fitton.
This is a good starting point for beginers to learn how to implement user input,
and how to select subsets at random.
- Simple simulation TOSSCOIN.BAS
of a 1000 tosses of a fair coin,
and related fair (or not) coin tosser HEADS.BAS
- A game of craps: compare theoretical answer (as found by the computer!)
with computer simulated probability in a game of craps by Chris Lowell.
- A simple example of blind search - find a max of a function of one variable.
(More complicated, but also more interesting is traveling salesman demo below.
- DBLINT.BAS
Double integral by Monte Carlo method (Chapter 2)
- A set of routines for poker simulation ( describing and printing cards,
fast card shuffling,, recognizing at least a pair in a hand; marked possible extensions).
- Simulation drivers.bas of n cars arriving at an intersection, answering
how often none has to stop.
- Two nice programs by Sonal Naik:
- The following programs are more advanced, and should be treated as ``demonstrations"
rather than easy-to-modify templates.
- RANDTOUR.BAS Demonstration of blind search for
traveling salesman example. There is also a more user-friendly executable Windows version (ZIP-compressed) which lets you fly over
any number of destinations in the USA.
- SALESMAN by NV Fitton is a nice DOS graphics traveling salesman solved by brute force..
- The probability of heads in tossing one coin is 50%. As the
simulation size increases, the simulated answer should converge
to theoretical value. Find out how often
in 2n tosses of a coin, you get 50% of heads. (The answer involves
pi!)
- LIMTHS.BAS Graphical illustration of important results:
Law of Large Numbers, Poisson approximation,
and Central Limit Theorem for Binomial trials (Chapter 5)
- FISH.BAS Watch the black fish disappear. (Illustration for
fish-transfer problem in the notes).We have also Fortan
and C-versions thanks to Anurag Gupta and Asad Rana.
- FIREWALK.BAS
Two dimensional
Wiener
process makes neat
pictures. (Chapter 6, or 10)
Once you have the
program on your disk,
type
QBASIC ProgramName /RUN
at
the DOS command line to run it. Alternatively, click on QBASIC.EXE from File Manager in Windows,
and then File/Open the file and select menu Run to run it.
W. Bryc
E-Mail: bryc@ucbeh.san.uc.edu