Serving the Quantitative Finance Community

  • 1
  • 4
  • 5
  • 6
  • 7
  • 8
 
User avatar
outrun
Posts: 4573
Joined: January 1st, 1970, 12:00 am

Re: Bivariate Normal Integral paper

March 6th, 2017, 1:27 pm

IMO this discussion is a comparison between uniform grid type of methods  v.s. non-uniform high order quadrature methods.

Even with extrapolation I expect the effectiveness of quadrature methods to be much better. E.g. for a trivariate I expect
that a 10x10x10 point quadrature will be much faster and more accurate than a 100x100x100 grid or extrapolations.

Also note w.r.t. making claims about flaws in methods that quadrature methods have positive weights, together with a positive pdf the probability can never be negative (unless some transform is done, I'll have to study that, but I have other more interesting projects I want to spend my limited time on).
 
User avatar
Cuchulainn
Posts: 20256
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Bivariate Normal Integral paper

March 6th, 2017, 1:33 pm

Even with extrapolation I expect the effectiveness of quadrature methods to be much better. E.g. for a trivariate I expect that a 10x10x10 point quadrature will be much faster and more accurate than a 100x100x100 grid or extrapolations.

Prove it.
'Expectation' is not enough. Numbers please. Do you have Espen's book? He does it in VBA.
And, as I mentioned, you don;t need 7 digits accuracy in M()  to get good option price. 

Now we have several choices, depending on the requirements. GW for one-off, FDM if you want a whole grid of values, for example Greeks.
Also note w.r.t. making claims about flaws in methods that quadrature methods have positive weights, together with a positive pdf the probability can never be negative (unless some transform is done

Reading section 4.3 shows DW2 solves negative option values.
 
User avatar
Cuchulainn
Posts: 20256
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Bivariate Normal Integral paper

March 6th, 2017, 1:57 pm

Test: 3 factor price

Here's a good test case: can you reproduce Table 2?

http://efinance.org.cn/cn/fe/Numerical% ... claims.pdf

Good luck.
 
User avatar
outrun
Posts: 4573
Joined: January 1st, 1970, 12:00 am

Re: Bivariate Normal Integral paper

March 6th, 2017, 2:38 pm

You'll have to prove it if you plan to claim otherwise. It's not my project.

You *do* need high precision numbers, the problem is that you have zero practical insight. How much margin doe you think an option trader makes on an option trade???
 
User avatar
outrun
Posts: 4573
Joined: January 1st, 1970, 12:00 am

Re: Bivariate Normal Integral paper

March 6th, 2017, 2:46 pm

Also, you haven't answered the extrapolation question. You claimed that I don't know nothing about extrapolation when I told you it would slow things down by a factor 4 or probdlby at least 16 if you wanted to have a 50x50 grid with 7 digits accuracy.

if you don't answer that then I will no longer help you stop digging this shit hole.
 
User avatar
outrun
Posts: 4573
Joined: January 1st, 1970, 12:00 am

Re: Bivariate Normal Integral paper

March 6th, 2017, 2:54 pm

1) Compute 50x50, report time and precision. We call this T1
2) use you fictional dream-on extrapolation to generate a 50x50 grid with 7 digits precision. Report time. We call this T2

send me T2/T1 bottles of good wine and I won't mention it again
 
User avatar
Cuchulainn
Posts: 20256
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Bivariate Normal Integral paper

March 6th, 2017, 3:23 pm

You'll have to prove it if you plan to claim otherwise. It's not my project.

You *do* need high precision numbers, the problem is that you have zero practical insight. How much margin doe you think  an option trader makes on an option trade???
I am comparing the results to Collector's VBA code. Is that enough accuracy?
 
User avatar
Cuchulainn
Posts: 20256
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Bivariate Normal Integral paper

March 6th, 2017, 3:24 pm

Also, you haven't answered the extrapolation question. You claimed that I don't know nothing about extrapolation when I told you it would slow things down by a factor 4 or probdlby at least 16 if you wanted to have a 50x50 grid with 7 digits accuracy.

if you don't answer that then I will no longer help you stop digging this shit hole.
Fine by me.

And please, don't post Python code here.
 
User avatar
outrun
Posts: 4573
Joined: January 1st, 1970, 12:00 am

Re: Bivariate Normal Integral paper

March 6th, 2017, 3:48 pm

The python code was to give you reference numbers, without it you can't claim things like "2-3" digit precision. I can keep posting things that are on topic, it's not *your* thread.

Collector VBA is not proffesional enough if you want to present "claim" results. Do you know the accuracy of that?

Funny that you keep evading things. Keep digging!
 
User avatar
outrun
Posts: 4573
Joined: January 1st, 1970, 12:00 am

Re: Bivariate Normal Integral paper

March 6th, 2017, 4:56 pm

The Python multiprecision is actually C++ code (as most pyhton libraries are). Indeed slow as hell. Nothing beats the GW, in VBA/Excel it takes < 1ms  :-)
Amazing. Long live VBA.

In the VBA code (GW??) in Haug's 2007 book it gives identically 0. Hmmm
HTH and prevent mistakes: you need to go to the Genz West paper they wrote themselves, it has code in figure 7. Arrays are 1 indexed as stated before
 
User avatar
Cuchulainn
Posts: 20256
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Bivariate Normal Integral paper

March 10th, 2017, 12:25 pm

Comparing Genz trivariate and Goursat 3d (on rough meshes); how much effort/function evaluations needed to achieve a given accuracy.

The FDM approach seems to scale to 3d quite well. You turn the knob to determine the level of accuracy needed.
//

***Trivariate, NX, NY, NZ: 5,5,5
 
** a,b, rho21, rho31, rho32: 6,0.34,5,0,0.8660254,-0.01
Goursat Classico NX: 0.599523504012804
Goursat Extrap 2*NX: 0.5672737978616413
Goursat Extrap 4*NX: 0.6535811570580227
Genz trivariate  0.6330715488562566
 
***Trivariate, NX, NY, NZ: 10,10,10
 
** a,b, rho21, rho31, rho32: 6,0.34,5,0,0.8660254,-0.01
Goursat Classico NX: 0.575336224399432
Goursat Extrap 2*NX: 0.6535811570580227
Goursat Extrap 4*NX: 0.6330657997160345
Genz trivariate  0.6330715488562566
 
***Trivariate, NX, NY, NZ: 15,15,15
 
** a,b, rho21, rho31, rho32: 6,0.34,5,0,0.8660254,-0.01
Goursat Classico NX: 0.6339577269600256
Goursat Extrap 2*NX: 0.6333295042229049
Goursat Extrap 4*NX: 0.6330708876660983
Genz trivariate  0.6330715488562566
 
***Trivariate, NX, NY, NZ: 20,20,20
 
** a,b, rho21, rho31, rho32: 6,0.34,5,0,0.8660254,-0.01
Goursat Classico NX: 0.634019923893375
Goursat Extrap 2*NX: 0.6330657997160345
Goursat Extrap 4*NX: 0.6330713519004104
Genz trivariate  0.6330715488562566
 
***Trivariate, NX, NY, NZ: 25,25,25
 
** a,b, rho21, rho31, rho32: 6,0.34,5,0,0.8660254,-0.01
Goursat Classico NX: 0.6336709039109505
Goursat Extrap 2*NX: 0.6330701496719837
Goursat Extrap 4*NX: 0.6330714779678041
Genz trivariate  0.6330715488562566
 
***Trivariate, NX, NY, NZ: 30,30,30
 
** a,b, rho21, rho31, rho32: 6,0.34,5,0,0.8660254,-0.01
Goursat Classico NX: 0.6334865599071851
Goursat Extrap 2*NX: 0.6330708876660983
Goursat Extrap 4*NX: 0.6330715231145035
Genz trivariate  0.6330715488562566
 
***Trivariate, NX, NY, NZ: 35,35,35
 
** a,b, rho21, rho31, rho32: 6,0.34,5,0,0.8660254,-0.01
Goursat Classico NX: 0.6333759285107489
Goursat Extrap 2*NX: 0.6330712006360999
Goursat Extrap 4*NX: 0.633071542435185
Genz trivariate  0.6330715488562566
 
***Trivariate, NX, NY, NZ: 40,40,40
 
** a,b, rho21, rho31, rho32: 6,0.34,5,0,0.8660254,-0.01
Goursat Classico NX: 0.6333043307603696
Goursat Extrap 2*NX: 0.6330713519004104
Goursat Extrap 4*NX: 0.6330715518026937
Genz trivariate  0.6330715488562566
 
***Trivariate, NX, NY, NZ: 45,45,45
 
** a,b, rho21, rho31, rho32: 6,0.34,5,0,0.8660254,-0.01
Goursat Classico NX: 0.6332553368798947
Goursat Extrap 2*NX: 0.6330714321801681
Goursat Extrap 4*NX: 0.633071556784604
Genz trivariate  0.6330715488562566
 
***Trivariate, NX, NY, NZ: 50,50,50
 
** a,b, rho21, rho31, rho32: 6,0.34,5,0,0.8660254,-0.01
Goursat Classico NX: 0.6332203382317254
Goursat Extrap 2*NX: 0.6330714779678041
Goursat Extrap 4*NX: 0.6330715596300344
Genz trivariate  0.6330715488562566
 
***Trivariate, NX, NY, NZ: 55,55,55
 
** a,b, rho21, rho31, rho32: 6,0.34,5,0,0.8660254,-0.01
Goursat Classico NX: 0.6331944680253506
Goursat Extrap 2*NX: 0.6330715056196582
Goursat Extrap 4*NX: 0.6330715613503234
Genz trivariate  0.6330715488562566
 
***Trivariate, NX, NY, NZ: 60,60,60
 
** a,b, rho21, rho31, rho32: 6,0.34,5,0,0.8660254,-0.01
Goursat Classico NX: 0.63317480572637
Goursat Extrap 2*NX: 0.6330715231145035
Goursat Extrap 4*NX: 0.6330715624395525
Genz trivariate  0.6330715488562566
 
***Trivariate, NX, NY, NZ: 65,65,65
 
** a,b, rho21, rho31, rho32: 6,0.34,5,0,0.8660254,-0.01
Goursat Classico NX: 0.6331595122602685
Goursat Extrap 2*NX: 0.6330715346191126
Goursat Extrap 4*NX: 0.6330715631563174
Genz trivariate  0.6330715488562566
 
***Trivariate, NX, NY, NZ: 70,70,70
 
** a,b, rho21, rho31, rho32: 6,0.34,5,0,0.8660254,-0.01
Goursat Classico NX: 0.6331473826047621
Goursat Extrap 2*NX: 0.633071542435185
Goursat Extrap 4*NX: 0.6330715636434827
Genz trivariate  0.6330715488562566
Last edited by Cuchulainn on March 10th, 2017, 12:38 pm, edited 2 times in total.
 
User avatar
Cuchulainn
Posts: 20256
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Bivariate Normal Integral paper

March 10th, 2017, 12:31 pm

A relevant remark is that the correlations rho21, rho31, rho32 must fit into the 'cushion' feasability region in order to produce a positive-definite correlation matrix, otherwise it goes haywire.

Thanks for the Mathematica jpg file!

i.e. [$] 1 - (x^2 + y^2 + z^2) + 2xyz > 0[$]
[$] x,y, z  \in [-1,1][$]



Image
 
User avatar
Cuchulainn
Posts: 20256
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Bivariate Normal Integral paper

March 11th, 2017, 11:19 am

I see that Quantlib supports Drezner1978 and Genz2004. The code looks well structured, although I have not yet run it. Most methods for seem to use Gauss (Legendre) methods.
https://github.com/lballabio/QuantLib/b ... bution.cpp

Taking randomly generated parameters in the empty quarters shows why Drezner 1978 is off. Genz 2004 can give very small negative values It's also about the range of parameter values for which an algorithm is accurate.

For this case the Goursat solution can be taken as exact.

 
a, b, rho: -7.485170763994502,-7.282245301211559, -0.3413596870645083
Goursat Classico          : 1.469659375772627e-39
Goursat Extrap            : 1.469660149582338e-39
Bivariate Tanh Integration: -0
Genz West                 : -8.817719401276176e-35
 
Drezner 1978             : 1.158880799983199e-31
Hull fix Drezner 1978     : 8.045175500162943e-32
 
a, b, rho: -7.486534863351317,-7.981978289170319, -0.2216407791282052
Goursat Classico          : 1.085431352824501e-37
Goursat Extrap            : 1.085431498679357e-37
Bivariate Tanh Integration: -0
Genz West                 : 2.589468763035098e-33
 
Drezner 1978             : 9.066381933009922e-34
Hull fix Drezner 1978     : 6.357222748215512e-34
 
a, b, rho: -7.457439643415576,-7.566086358319964, 0.3552388689329968
Goursat Classico          : 3.830635479326228e-21
Goursat Extrap            : 3.830635780025568e-21
Bivariate Tanh Integration: -4.634994606600033e-18
Genz West                 : 4.313766952287983e-21
 
Drezner 1978             : 6.040992379909876e-11
Hull fix Drezner 1978     : 5.627068270804976e-11
 
a, b, rho: -7.572621427486137,-7.425746466338564, 0.5218551590516818
Goursat Classico          : 5.4281834770519e-19
Goursat Extrap            : 5.428183825737561e-19
Bivariate Tanh Integration: -4.551154093839461e-16
Genz West                 : 6.305368289138139e-19
 
Drezner 1978             : 7.93085400119523e-12
Hull fix Drezner 1978     : 7.333719115749188e-12
 
a, b, rho: -7.387118812130974,-7.393968182050283, -0.9528925356794802
Goursat Classico          : 0
Goursat Extrap            : 0
Bivariate Tanh Integration: -0
Genz West                 : 0
 
Drezner 1978             : 1.195770632401737e-07
Hull fix Drezner 1978     : 1.146784206106627e-07
 
a, b, rho
 
User avatar
Cuchulainn
Posts: 20256
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Bivariate Normal Integral paper

March 13th, 2017, 10:30 am

Quant:Lib supports Genz 2004 and Drezner 1978 (~ 4 digits accuracy indeed as discussed in the literature which seems to state 6 digits accuracy).
The interface to QL is quite clear.

a, b, rho: -4.01038,-0.331563, -0.932353
*Goursat Classico          : 4.008862448300886e-35
*Goursat Extrap            : 4.010481556467851e-35
*Genz West                 : 4.010486245890782e-35
*Genz QuantLib 1.8         : 4.010481276199955e-35
*Drezner 1978 Quantlib 1.8 : 2.501045949767056e-35

a, b, rho: -2.263552162868057,2.21920689521494, 0.3133380985259988
*Goursat Classico          : 0.01179221565427344
*Goursat Extrap            : 0.01179222776416807
*Genz West                 : 0.0117922277641472
*Genz QuantLib 1.8         : 0.01179222776414719
*Drezner 1978 Quantlib 1.8 : 0.01179223673518974

a, b, rho: 3.477626552849689,-0.3099597067727089, 0.8522142132765318
*Goursat Classico          : 0.3782957617797055
*Goursat Extrap            : 0.3782957988198388
*Genz West                 : 0.3782957988205818
*Genz QuantLib 1.8         : 0.3782957988205817
*Drezner 1978 Quantlib 1.8 : 0.3782957988205826

a, b, rho: -1.305808252181629,5.270107893539638, -0.9226141693879427
*Goursat Classico          : 0.09580876546524203
*Goursat Extrap            : 0.095808818355759
*Genz West                 : 0.09580881835582941
*Genz QuantLib 1.8         : 0.0958088183558294
*Drezner 1978 Quantlib 1.8 : 0.09580881835582922

a, b, rho: 5.427037108624948,-7.647800925713791, -0.799654167438639
*Goursat Classico          : 9.672354704129521e-16
*Goursat Extrap            : 9.67241214171905e-16
*Genz West                 : 9.917489340290059e-16
*Genz QuantLib 1.8         : 9.917490239523412e-16
*Drezner 1978 Quantlib 1.8 : 9.992007221626409e-16

a, b, rho: -7.570404820382103,-4.664949791135294, -0.6541855509321741
*Goursat Classico          : 1.846468274403044e-51
*Goursat Extrap            : 1.846500169984213e-51
*Genz West                 : -2.922184254557723e-28
*Genz QuantLib 1.8         : -4.561267155992896e-29
*Drezner 1978 Quantlib 1.8 : 9.199789165334495e-52

a, b, rho: -7.837486538418611,-4.985326557354989, 0.9547257653639707
*Goursat Classico          : 1.567758144223561e-15
*Goursat Extrap            : 1.567757987300642e-15
*Genz West                 : 2.298271020853247e-15
*Genz QuantLib 1.8         : 2.298271041302458e-15
*Drezner 1978 Quantlib 1.8 : 2.298271041302458e-15

a, b, rho: -0.9300945368105022,-3.904999214554652, 0.385484325066676
*Goursat Classico          : 3.59535448974756e-05
*Goursat Extrap            : 3.595358902176324e-05
*Genz West                 : 3.595358902267761e-05
*Genz QuantLib 1.8         : 3.595358902268021e-05
*Drezner 1978 Quantlib 1.8 : 3.597724924239009e-05

a, b, rho: 5.999660133703264,-7.221410212208445, 0.369152450910327
*Goursat Classico          : 2.56633801702284e-13
*Goursat Extrap            : 2.566338455868534e-13
*Genz West                 : 2.572559418316852e-13
*Genz QuantLib 1.8         : 2.57255943388781e-13
*Drezner 1978 Quantlib 1.8 : 2.57255943388781e-13

a, b, rho: -5.38344498094517,-1.243404342163801, 0.6985789013711452
*Goursat Classico          : 3.653199134814573e-08
*Goursat Extrap            : 3.653203108035183e-08
*Genz West                 : 3.653203211123947e-08
*Genz QuantLib 1.8         : 3.653203211199293e-08
*Drezner 1978 Quantlib 1.8 : 3.653215397794543e-08
 
User avatar
Cuchulainn
Posts: 20256
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Bivariate Normal Integral paper

March 13th, 2017, 12:31 pm

QuantLib supports bivariate Student cumulative. Can we reproduce its output?

An open issue is to choose the truncation values (here we took -50..)

Goursat for trivariate Student is a piece of cake to do.

a, b, rho: 1.32064990678,2.6719942742, 0.793189848038
Goursat Classico          : 0.8678871534019083
Goursat Extrap            : 0.867886160393165
BVT QuantLib 1.8          : 0.867886872082

a, b, rho: 3.30387440369,2.86343908197, 0.735444082351
Goursat Classico          : 0.9706980599555227
Goursat Extrap            : 0.9706978359878865
BVT QuantLib 1.8          : 0.970698566469

a, b, rho: 1.40303924459,1.19472961942, 0.985080105199
Goursat Classico          : 0.8472957035144354
Goursat Extrap            : 0.8472930323954148
BVT QuantLib 1.8          : 0.847293579975

a, b, rho: 2.61489902654,0.954624363986, 0.899377475415
Goursat Classico          : 0.8024229680432897
Goursat Extrap            : 0.8024218262176394
BVT QuantLib 1.8          : 0.802422479214

a, b, rho: 4.19269483635,2.65839851916, -0.668423714729
Goursat Classico          : 0.964950032066738
Goursat Extrap            : 0.9649498081035399
BVT QuantLib 1.8          : 0.964949864807

a, b, rho: 3.21346928548,0.846326940072, -0.611668803542
Goursat Classico          : 0.7620072575889444
Goursat Extrap            : 0.762006032979415
BVT QuantLib 1.8          : 0.762006107304

a, b, rho: 2.9303564708,0.478141889928, -0.280314771607
Goursat Classico          : 0.6545963202621341
Goursat Extrap            : 0.6545952936872909
BVT QuantLib 1.8          : 0.654595556753

a, b, rho: 1.8801029762,0.00597176058652, -0.76516090897
Goursat Classico          : 0.4386411087102223
Goursat Extrap            : 0.4386406652874202
BVT QuantLib 1.8          : 0.43864068703

a, b, rho: 5.16747017438,1.80136280011, -0.560642822639
Goursat Classico          : 0.923807324135712
Goursat Extrap            : 0.9238067551374721
BVT QuantLib 1.8          : 0.923806861261

a, b, rho: 1.52675404433,0.515367259334, 0.229522610219
Goursat Classico          : 0.6331041395963604
Goursat Extrap            : 0.6331026998023744
BVT QuantLib 1.8          : 0.633103305167