Home > wafo > trgauss > bvnormprb.m

# bvnormprb

## PURPOSE

Bivariate Normal probability

## SYNOPSIS

value = bvnormprb(lower,upper,correl)

## DESCRIPTION

``` BVNORMPRB Bivariate Normal probability

CALL prb = bvnormprb(a,b,r)

prb = computed probability
a   = vector with lower integration limits
b   = vector with upper integration limits
r   = correlation coefficient

BVNORMPRB computes bivariate normal probability, i.e.,
the probability Prob(A(1) <= X1 <= B(1) and A(2) <= X2 <= B(2))
with an absolute error less than 1e-15.

Example
a = [-1 -2];
b = [1 1];
r = 0.3;
bvnormprb(a,b,r)

## CROSS-REFERENCE INFORMATION

This function calls:
 bvnormcdf Bivariate Normal cumulative distribution function error Display message and abort function.
This function is called by:

## SOURCE CODE

```001 function value = bvnormprb(lower,upper,correl)
002 %BVNORMPRB Bivariate Normal probability
003 %
004 %  CALL prb = bvnormprb(a,b,r)
005 %
006 % prb = computed probability
007 % a   = vector with lower integration limits
008 % b   = vector with upper integration limits
009 % r   = correlation coefficient
010 %
011 % BVNORMPRB computes bivariate normal probability, i.e.,
012 %  the probability Prob(A(1) <= X1 <= B(1) and A(2) <= X2 <= B(2))
013 %  with an absolute error less than 1e-15.
014 %
015 % Example
016 %  a = [-1 -2];
017 %  b = [1 1];
018 %  r = 0.3;
019 %  bvnormprb(a,b,r)
020 %
022
023 error(nargchk(3,3,nargin))
024 value = 1;
025 infinity = 37;
026 if all(lower <= -infinity & upper>= infinity),
027   return,
028 end
029 if any(lower>=upper),
030   value=0;
031   return,
032 end
033
034 infin =[2; 2]-(upper(:)>infinity)-2*(lower(:)<-infinity);
035
036 if all(infin==2)
037   value =  bvd ( lower(1), lower(2), correl )...
038       - bvd ( upper(1), lower(2), correl )...
039       - bvd ( lower(1), upper(2), correl )...
040       + bvd ( upper(1), upper(2), correl );
041 elseif ( infin(1) == 2  & infin(2) == 1 )
042   value =  bvd ( lower(1), lower(2), correl )...
043       - bvd ( upper(1), lower(2), correl );
044 elseif ( infin(1) == 1  & infin(2) == 2 )
045   value =  bvd ( lower(1), lower(2), correl )....
046       - bvd ( lower(1), upper(2), correl );
047 elseif ( infin(1) == 2  & infin(2) == 0 )
048   value =  bvd ( -upper(1), -upper(2), correl )...
049       - bvd ( -lower(1), -upper(2), correl );
050 elseif ( infin(1) == 0  & infin(2) == 2 )
051   value =  bvd ( -upper(1), -upper(2), correl )....
052       - bvd ( -upper(1), -lower(2), correl );
053 elseif ( infin(1) == 1  & infin(2) == 0 )
054   value =  bvd ( lower(1), -upper(2), -correl );
055 elseif ( infin(1) == 0  & infin(2) == 1 )
056   value =  bvd ( -upper(1), lower(2), -correl );
057 elseif ( infin(1) == 1  & infin(2) == 1 )
058   value =  bvd ( lower(1), lower(2), correl );
059 elseif ( infin(1) == 0  & infin(2) == 0 )
060   value =  bvd ( -upper(1), -upper(2), correl );
061 end
062 return
063
064 function val = bvd(lo,up,r)
065   val = bvnormcdf(-lo,-up,r);
066 return```

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group

Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003