-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Python for Finance

Normal distributions play a central role in finance. A major reason is that many finance theories, such as option theory and their related applications, are based on the assumption that stock returns follow a normal distribution. The second reason is that if our econometric models are well designed, the error terms from the models should follow a zero-mean normal distribution. It is a common task that we need to generate n random numbers from a standard normal distribution. For this purpose, we have the following three lines of code:
import scipy as sp x=sp.random.standard_normal(size=10) print(x) [-0.98350472 0.93094376 -0.81167564 -1.83015626 -0.13873015 0.33408835 0.48867499 -0.17809823 2.1223147 0.06119195]
The basic random numbers in SciPy/NumPy are created by Mersenne Twister PRNG in the numpy.random
function. The random numbers for distributions in numpy.random
are in cython/pyrex and are pretty fast. There is no...
Change the font size
Change margin width
Change background colour