SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
User avatar
Cuchulainn
Topic Author
Posts: 61185
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

The "best" method to compute bivariate cumulative normal distribution

December 31st, 2015, 1:07 pm

What is the best method for"Best" is in eye of beholder but the following are a good start:1. Efficiency (aka fast, the easy one)2. Adaptability to 1) other distributions 2) multi-variate versions3. Robustness for all x,y and rho4. Accuracy for all x,y and rho5. Effort needed to implement the numerical approximation (I'm assuming no one has a closed solution ;).. but you never can tell)6. Maintainability of the code7. Double and multiprecision versionsEast-west, what's best?
Last edited by Cuchulainn on December 30th, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
list1
Posts: 1696
Joined: July 22nd, 2015, 2:12 pm

The "best" method to compute bivariate cumulative normal distribution

December 31st, 2015, 2:28 pm

When we have an explicit formula it is assumed that [$]\rho[$] is given. The first idea to present transformation to present formula as the product of two independent normal distributed variables
 
User avatar
katastrofa
Posts: 8772
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

The "best" method to compute bivariate cumulative normal distribution

December 31st, 2015, 3:11 pm

What about transforming the variables x and y into percentiles of marginal distributions so that the integration limits become finite and next using some adaptive polynomial methods or whatever (Gauss--Kronrod)? It probably won't work too well for high correlations though...
Last edited by katastrofa on December 30th, 2015, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Topic Author
Posts: 61185
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

The "best" method to compute bivariate cumulative normal distribution

December 31st, 2015, 3:39 pm

QuoteOriginally posted by: katastrofaWhat about transforming the variables x and y into percentiles of marginal distributions so that the integration limits become finite and next using some adaptive polynomial methods or whatever (Gauss--Kronrod)? It probably won't work too well for high correlations though...This is certainly an option. I have not tried it yet. High correlation is an issue with almost all methods. For 3-variate and above what can we do. It's a lot of function calls.Most solutions seem to be similar to this
Last edited by Cuchulainn on December 30th, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Topic Author
Posts: 61185
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

The "best" method to compute bivariate cumulative normal distribution

December 31st, 2015, 3:40 pm

QuoteOriginally posted by: list1When we have an explicit formula it is assumed that [$]\rho[$] is given. The first idea to present transformation to present formula as the product of two independent normal distributed variablesIt is not allowed to reduce scope of problem because correlation cannot be zero. Most people do _not_ believe an explicit computable formula exists. What is the transformation? Are you saying transform correlated variables to uncorrelated ones, compute the latter's cdf and then transform back in some way? Interesting idea. ==So, with [$]\rho = 0[$] we can just convert to polar coordinates?
Last edited by Cuchulainn on December 30th, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
list1
Posts: 1696
Joined: July 22nd, 2015, 2:12 pm

The "best" method to compute bivariate cumulative normal distribution

December 31st, 2015, 4:46 pm

over Formula[$] \frac{x^2\, -\, 2\rho\,x\,y\, +\,y^2}{1\,-\,\rho^2}\,\,=\,\, \frac{(\,x\, -\, \rho y\,)^2 \,\, +\,\,(\,1\,-\,\rho^2\,)\,y^2}{1\,-\,\rho^2}[$]suggests to introduce new variables [$] U \,\,=\,\, \frac{X\,-\,\rho\,Y}{\sqrt {1\,-\,\rho^2}}[$][$] V \,\,=\,\, Y[$]where X, Y are original correlated pair of random variables. Then we need to transform dx dy to du dv using Hessian of transformation and then integration limits for v will be the same as for y and internal integral for x over the interval ( -inf , a ] will be transform into interval (-inf , [$]\frac{a\,-\,\rho\,y}{\sqrt {1\,-\,\rho^2}}[$]]
Last edited by list1 on December 30th, 2015, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Topic Author
Posts: 61185
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

The "best" method to compute bivariate cumulative normal distribution

December 31st, 2015, 4:56 pm

QuoteOriginally posted by: list1over Formula[$] \frac{x^2\, -\, 2\rho\,x\,y\, +\,y^2}{1\,-\,\rho^2}\,\,=\,\, \frac{(\,x\, -\, \rho y\,)^2 \,\, +\,\,(\,1\,-\,\rho^2\,)\,y^2}{1\,-\,\rho^2}[$]suggests to introduce new variables [$] U \,\,=\,\, \frac{X\,-\,\rho\,Y}{\sqrt {1\,-\,\rho^2}}[$][$] V \,\,=\,\, Y[$]where X, Y are original correlated pair of random variables. Then we need to transform dx dy to du dv using Hessian of transformation and then integration limits for v will be the same as for y and internal integral for x over the interval ( -inf , a ] will be transform into interval (-inf , [$]\frac{a\,-\,\rho\,y}{\sqrt {1\,-\,\rho^2}}[$]]That looks nice; I suppose there is a similar upper limit for b?
Last edited by Cuchulainn on December 30th, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
katastrofa
Posts: 8772
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

The "best" method to compute bivariate cumulative normal distribution

December 31st, 2015, 4:57 pm

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: list1When we have an explicit formula it is assumed that [$]\rho[$] is given. The first idea to present transformation to present formula as the product of two independent normal distributed variablesIt is not allowed to reduce scope of problem because correlation cannot be zero. Most people do _not_ believe an explicit computable formula exists. What is the transformation? Are you saying transform correlated variables to uncorrelated ones, compute the latter's cdf and then transform back in some way? Interesting idea. ==So, with [$]\rho = 0[$] we can just convert to polar coordinates?It's not about reducing the problem. You can always diagonalise the covariance matrix to obtain the product of some new variables' densities. I preferred my answer, because I assumed that this solution (the product) would give some numerically unfeasible integration limits.
Last edited by katastrofa on December 30th, 2015, 11:00 pm, edited 1 time in total.
 
User avatar
list1
Posts: 1696
Joined: July 22nd, 2015, 2:12 pm

The "best" method to compute bivariate cumulative normal distribution

December 31st, 2015, 5:30 pm

K, I do not know which way is better. It also depends on which form we wish to get the answer
Last edited by list1 on December 30th, 2015, 11:00 pm, edited 1 time in total.
 
User avatar
EBal
Posts: 431
Joined: May 20th, 2005, 1:30 pm

The "best" method to compute bivariate cumulative normal distribution

December 31st, 2015, 5:40 pm

QuoteOriginally posted by: CuchulainnWhat is the best method for"Best" is in eye of beholder but the following are a good start:1. Efficiency (aka fast, the easy one)2. Adaptability to 1) other distributions 2) multi-variate versions3. Robustness for all x,y and rho4. Accuracy for all x,y and rho5. Effort needed to implement the numerical approximation (I'm assuming no one has a closed solution ;).. but you never can tell)6. Maintainability of the code7. Double and multiprecision versionsEast-west, what's best?Taking what list1 suggested one step further, you can transform this double integral to an ordinary integral, and use your favorite method to compute it[$]\frac{1}{\sqrt{2\pi}} \int_{-\infty}^b dy\, e^{-y^2/2} N\left(\frac{a-\rho y}{\sqrt{1-\rho^2}}\right)[$]where [$]N[$] is cumulative normal function. Most likely, there is no closed form solution to the ordinary integral, except for special values of [$]a[$], [$]\rho[$].
Last edited by EBal on December 30th, 2015, 11:00 pm, edited 1 time in total.
 
User avatar
katastrofa
Posts: 8772
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

The "best" method to compute bivariate cumulative normal distribution

December 31st, 2015, 5:54 pm

Isn't the fact that the integration limits are no longer rectangular a problem for most methods?
 
User avatar
Cuchulainn
Topic Author
Posts: 61185
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

The "best" method to compute bivariate cumulative normal distribution

January 1st, 2016, 3:22 pm

QuoteOriginally posted by: CuchulainnWhat is the best method forOne requirement is efficiency. By the Fubini-Tonelli theorem we know that [$]M(a,b;\rho) = M(b,a;\rho)[$] (you can also double-check it numerically). So if we are creating a table of values for a discrete range of [$]a[$] and [$]b[$] then we only need to compute [$]M(a,b;\rho), a \ge b[$]. The results can be put in a symmetric matrix. This way you do half the work compared to a more naïve approach, which should be modified.
Last edited by Cuchulainn on December 31st, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Traden4Alpha
Posts: 23951
Joined: September 20th, 2002, 8:30 pm

The "best" method to compute bivariate cumulative normal distribution

January 1st, 2016, 4:10 pm

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: CuchulainnWhat is the best method forOne requirement is efficiency. By the Fubini-Tonelli theorem we know that [$]M(a,b;\rho) = M(b,a;\rho)[$] (you can also double-check it numerically). So if we are creating a table of values for a discrete range of [$]a[$] and [$]b[$] then we only need to compute [$]M(a,b;\rho), a \ge b[$]. The results can be put in a symmetric matrix. This way you do half the work compared to a more naïve approach, which should be modified.If one has an efficient way to compute the univariate cumulative normal, then there's also ways to do half the work by only computing the [$]\rho \ge 0[$] case
Last edited by Traden4Alpha on December 31st, 2015, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Topic Author
Posts: 61185
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

The "best" method to compute bivariate cumulative normal distribution

January 1st, 2016, 4:49 pm

QuoteOriginally posted by: Traden4AlphaQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: CuchulainnWhat is the best method forOne requirement is efficiency. By the Fubini-Tonelli theorem we know that [$]M(a,b;\rho) = M(b,a;\rho)[$] (you can also double-check it numerically). So if we are creating a table of values for a discrete range of [$]a[$] and [$]b[$] then we only need to compute [$]M(a,b;\rho), a \ge b[$]. The results can be put in a symmetric matrix. This way you do half the work compared to a more naïve approach, which should be modified.If one has an efficient way to compute the univariate cumulative normal, then there's also ways to do half the work by only computing the [$]\rho \ge 0[$] caseCan do. This is the numerical equivalent of the iterated integral form of Fubini-Tonelli. The caveat is that it is a numerical approximation of a numerical approximation to a continuous function, which can be messy sometimes. And it will be not easy for trivariate and quadvariate distributions.The iterated integral approach is what many authors use. It is possible to treat it as a 2d problem from first principles as it were (later). // People seem to be assuming the solution is closely related to doing stuff 'directly' with integrals.
Last edited by Cuchulainn on December 31st, 2015, 11:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
Cuchulainn
Topic Author
Posts: 61185
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

The "best" method to compute bivariate cumulative normal distribution

January 1st, 2016, 5:02 pm

Emerging requirement:8. ParallelisationHow easy to implement?
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On