Many financial problems could be summarized as or associated with the maximum or minimum of several assets. Let's look at a simple one: options on the maximum or minimum of two assets. These type of options are called rainbow options. Since two assets are involved, we have to get familiar with a so-called bivariate normal distribution. The following codes show its graph. The original codes are at the website of http://scipython.com/blog/visualizing-the-bivariate-gaussian-distribution/:
import numpy as np from matplotlib import cm import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D # # input area n = 60 # number of intervals x = np.linspace(-3, 3, n) # x dimension y = np.linspace(-3, 4, n) # y dimension x,y = np.meshgrid(x, y) # grid # # Mean vector and covariance matrix mu = np.array([0., 1.]) cov= np.array([[ 1. , -0.5], [-0.5, 1.5]]) # # combine x and y into a single 3-dimensional array pos = np.empty(x.shape +...