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

Python for Finance

Quite often, users want to produce the same set of random numbers repeatedly. For example, when a professor is explaining how to estimate the mean, standard deviation, skewness, and kurtosis of a set of random numbers, it is a good idea that students could generate exactly the same values as their instructor. Another example would be that when we are debugging our Python program to simulate a stock's movements, we might prefer to have the same intermediate results. For such cases, we use the scipy.random.seed()
function as follows:
>>>import scipy as sp >>>sp.random.seed(12345) >>>x=sp.random.normal(0,1,20) >>>print x[0:5] [-0.20470766 0.47894334 -0.51943872 -0.5557303 1.96578057] >>>
Here, 12345
is a seed. The value of the seed is not important. The key is that the same seed leads to the same set of random values. The formula for a more general normal distribution is shown here:
Here, f(x) is the...
Change the font size
Change margin width
Change background colour