Abstract
Random numbers have many applications in science and computer programming, especially when there are significant uncertainties in a phenomenon of interest. The purpose of this chapter is to look at some practical problems involving random numbers and learn how to program with such numbers. We shall make several games and also look into how random numbers can be used in physics. A particularly important topic is Monte Carlo simulation for estimating probabilities.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
In the half open interval [0,1) the lower limit is included, but the upper limit is not.
- 2.
What it means to view the numbers as random has fortunately a firm mathematical foundation, so don’t let the fact that random numbers are deterministic stop you from using them.
- 3.
Textbooks in statistics teach you that it is more appropriate to divide by n−1 instead of n, but we are not going to worry about that fact in this book.
- 4.
For example, the blood pressure among adults of one gender has values that follow a normal distribution.
- 5.
This term is also applied for programs that solve equations arising in mathematical models in general, but it is particularly common to use the term when random numbers are used to estimate probabilities.
- 6.
“As far as the laws of mathematics refer to reality, they are not certain, as far as they are certain, they do not refer to reality.” –Albert Einstein, physicist, 1879–1955.
- 7.
You may try this yourself: flip the coin and make one step to the left or right, and repeat this process.
- 8.
These actions require from scitools.std import * and import time.
- 9.
The probability is \(2^{-n_{s}}\), which becomes about 10−9 for 30 steps.
- 10.
The number of bins in the histogram is just based on the extent of the particles. It could also have been a fixed number.
- 11.
If you want to run this command from an IPython session, prefix convert with an exclamation mark: !convert.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2012 Springer-Verlag Berlin Heidelberg
About this chapter
Cite this chapter
Langtangen, H.P. (2012). Random Numbers and Simple Games. In: A Primer on Scientific Programming with Python. Texts in Computational Science and Engineering, vol 6. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-30293-0_8
Download citation
DOI: https://doi.org/10.1007/978-3-642-30293-0_8
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-30292-3
Online ISBN: 978-3-642-30293-0
eBook Packages: Mathematics and StatisticsMathematics and Statistics (R0)