Table of Contents


File

my_trirnd.m

Name

my_trirnd

Synopsis

my_trirnd - creates a sample of random variables from a triangular distribution.

Introduction

NOTE: PART OF A SET OF 2 RELATED FILES:

The Distressed Insurance Premium (DIP) is proposed as an ex ante systemic risk metric by Huang, Zhou, and Zhu (2009b) and it represents a hypothetical insurance premium against a systemic financial distress, defined as total losses that exceed a given threshold, say 15%, of total bank liabilities. The methodology is general and can apply to any pre-selected group of firms with publicly tradable equity and CDS contracts. Each institutions marginal contribution to systemic risk is a function of its size, probability of default (PoD), and asset correlation. The last two components need to be estimated from market data.

License

=============================================================================

Copyright 2011, Dimitrios Bisias, Andrew W. Lo, and Stavros Valavanis

COPYRIGHT STATUS: This work was funded in whole or in part by the Office of Financial Research under U.S. Government contract TOSOFR-11-C-0001, and is, therefore, subject to the following license: The Government is granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide license to reproduce, prepare derivative works, distribute copies to the public, perform and display the work.
All other rights are reserved by the copyright owner.

THIS SOFTWARE IS PROVIDED "AS IS". YOU ARE USING THIS SOFTWARE AT YOUR OWN RISK. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS, OR THE UNITED STATES GOVERNMENT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

=============================================================================

Inputs

min_val
Name:
min_val
Description:

The minimum value of the support function of the triangular distribution. (For probability of default should lie in [0,1].)

Type:
float
Range:
(-inf,+inf)
Dimensions:

scalar


mode
Name:
mode
Description:

The mode of the distribution. (For probability of default this should lie in [0,1].)

Type:
float
Range:
(-inf,+inf)
Dimensions:

scalar


max_val
Name:
max_val
Description:

The max value of the support function of the triangular distribution. (For probability of default this should lie in [0,1].)

Type:
float
Range:
(-inf,+inf)
Dimensions:

scalar


n
Name:
n
Description:

The number of samples that will be created.

Type:
integer
Range:
{1,...,+inf}
Dimensions:

scalar


Outputs

r
Name:
r
Description:

A modified random distribution of loss probabilities used to calculate Loss Given Default (LGD). The number of rows is provided by input parameter n passed from parent function default_insurance_premium.m

Type:
float
Range:
(0,+inf)
Dimensions:

Nx1 matrix, where N = input parameter n.

  1. Rows represent each of N repetitions.

Code

% Run warning message
warning('OFRwp0001:UntestedCode', ...
    ['This version of the source code is very preliminary, ' ...
     'and has not been thoroughly tested. Users should not rely on ' ...
     'these calculations.']);


%
% Parameters:
% min_val The min value of the support function of the triangular
% distribution
% mode The mode of the distribution
% max_val The max value of the support function of the triangular
% distribution
% n The number of samples will be created

% This is the cdf for the mode. For a symmetric triangular distribution
% will be 0.5
F_mode = (mode-min_val)^2/((max_val-min_val)*(mode-min_val));

% Create a uniform random vector
u = rand(n,1);

r = zeros(n,1);
% Create the random sample
for i=1:n
    if u(i)<F_mode
        r(i) = min_val + sqrt(u(i)*(max_val-min_val)*(mode-min_val));
    else
        r(i) = max_val - sqrt((1-u(i))*(max_val-min_val)*(max_val-mode));
    end
end

Examples

NOTE: Numbers used in the examples are arbitrary valid values.
They do not necessarily represent a realistic or plausible scenario.

 min_val = 0.5;
 mode = 1;
 max_val = 1.5;
 n = 8;

 r = my_trirnd(min_val, mode, max_val, n);

References

Huang, X., Zhou, H., & Zhu, H. (2009). A framework for assessing the systemic risk of major financial institutions. Journal of Banking & Finance, 33(11), 2036-2049.

Bisias et al. (2012). A survey of systemic risk analytics (Working paper #0001). Washington, DC: Office of Financial Research, 108-112.