80 likes | 203 Views
By Cheng Few Lee Joseph Finnerty John Lee Alice C Lee Donald Wort. Appendix 19 A Microsoft Excel Program for Calculating Cumulative Bivariate Normal Density Function ( 19.8.2). Option Explicit Public Function Bivarncdf (a As Double, b As Double, rho As Double) As Double
E N D
By Cheng Few Lee Joseph Finnerty John Lee Alice C Lee Donald Wort Appendix 19 AMicrosoft Excel Program for Calculating Cumulative Bivariate Normal Density Function(19.8.2)
Option Explicit • Public Function Bivarncdf(a As Double, b As Double, rho As Double) As Double • Dim rho_ab As Double, rho_ba As Double • Dim delta As Double • If (a * b * rho) <= 0 Then • If (a <= 0 And b <= 0 And rho <= 0) Then • Bivarncdf = Phi(a, b, rho) • End If • If (a <= 0 And b >= 0 And rho > 0) Then • Bivarncdf = Application.WorksheetFunction.NormSDist(a) - Phi(a, -b, -rho) • End If • If (a >= 0 And b <= 0 And rho > 0) Then • Bivarncdf = Application.WorksheetFunction.NormSDist(b) - Phi(-a, b, -rho) • End If • If (a >= 0 And b >= 0 And rho <= 0) Then • Bivarncdf = Application.WorksheetFunction.NormSDist(a) + Application.WorksheetFunction.NormSDist(b) - 1 + Phi(-a, -b, rho) • End If • Else • rho_ab = ((rho * a - b) * IIf(a >= 0, 1, -1)) / Sqr(a ^ 2 - 2 * rho * a * b + b ^ 2) • rho_ba = ((rho * b - a) * IIf(b >= 0, 1, -1)) / Sqr(a ^ 2 - 2 * rho * a * b + b ^ 2) • delta = (1 - IIf(a >= 0, 1, -1) * IIf(b >= 0, 1, -1)) / 4 • Bivarncdf = Bivarncdf(a, 0, rho_ab) + Bivarncdf(b, 0, rho_ba) - delta • End If • End Function
Public Function Phi(a As Double, b As Double, rho As Double) As Double • Dim a1 As Double, b1 As Double • Dim w(5) As Double, x(5) As Double • Dim i As Integer, j As Integer • Dim doublesum As Double • a1 = a / Sqr(2 * (1 - rho ^ 2)) • b1 = b / Sqr(2 * (1 - rho ^ 2)) • w(1) = 0.24840615 • w(2) = 0.39233107 • w(3) = 0.21141819 • w(4) = 0.03324666 • w(5) = 0.00082485334 • x(1) = 0.10024215 • x(2) = 0.48281397 • x(3) = 1.0609498 • x(4) = 1.7797294 • x(5) = 2.6697604 • doublesum = 0 • For i = 1 To 5 • For j = 1 To 5 • doublesum = doublesum + w(i) * w(j) * Exp(a1 * (2 * x(i) - a1) + b1 * (2 * x(j) - b1) + 2 * rho * (x(i) - a1) * (x(j) - b1)) • Next j • Next i • Phi = 0.31830989 * Sqr(1 - rho ^ 2) * doublesum • End Function
By Cheng Few Lee Joseph Finnerty John Lee Alice C Lee Donald Wort Appendix 19 BMicrosoft Excel Program for Calculating American Call Options(19.8.2)