Python for Finance: Analyze Big Financial Data

(Elle) #1

Since we have assumed a highly negative mean for the jump, it should not come as a


surprise that the final values of the simulated index level are more right-skewed in


Figure 10-13 compared to a typical log-normal distribution:


In  [ 43 ]: plt.hist(S[- 1 ],   bins= 50 )
plt.xlabel(‘value’)
plt.ylabel(‘frequency’)
plt.grid(True)

Figure 10-13. Simulated jump diffusion at maturity

The highly negative jumps can also be found in the first 10 simulated index level paths, as


presented in Figure 10-14:


In  [ 44 ]: plt.plot(S[:,   : 10 ], lw=1.5)
plt.xlabel(‘time’)
plt.ylabel(‘index level’)
plt.grid(True)

Figure 10-14. Simulated jump diffusion paths

Variance Reduction


Not only because of the fact that the Python functions we have used so far generate


pseudorandom numbers, but also due to the varying sizes of the samples drawn, resulting


sets of numbers might not exhibit statistics really close enough to the expected/desired


ones. For example, you would expect a set of standard normally distributed random


numbers to show a mean of 0 and a standard deviation of 1. Let us check what statistics


different sets of random numbers exhibit. To achieve a realistic comparison, we fix the


seed value for the random number generator:

Free download pdf