• ะ•ัˆา›ะฐะฝะดะฐะน ะำ™ั‚ะธะถะต ะขะฐะฑั‹ะปา“ะฐะฝ ะ–ะพา›

Robust Prediction with Risk Measures

N/A
N/A
Protected

Academic year: 2024

Share "Robust Prediction with Risk Measures"

Copied!
50
0
0

ะขะพะปั‹า› ะผำ™ั‚ั–ะฝ

(1)

Robust Prediction with Risk Measures

by

Yerlan Duisenbay

Submitted to the Department of Mathematics

in partial fulfillment of the requirements for the degree of Master of Science in Applied Mathematics

at the

NAZARBAYEV UNIVERSITY Apr 2020

โ—‹ c Nazarbayev University 2020. All rights reserved.

Author . . . . Department of Mathematics

Apr 29, 2020

Certified by . . . . Kerem Ugurlu Assistant Professor Thesis Supervisor

Accepted by . . . .

Daniel Pugh

Dean, School of Sciences and Humanities

(2)
(3)

Robust Prediction with Risk Measures

by

Yerlan Duisenbay

Submitted to the Department of Mathematics on Apr 29, 2020, in partial fulfillment of the

requirements for the degree of Master of Science in Applied Mathematics

Abstract

This thesis deals with coherent risk measures and its simulation with respect to dif- ferent probability distributions. This study gives a numerical scheme to approximate any coherent risk measure via a sum of specific quantiles. We give the theoretical background on coherent risk measures in the first part and in the second part of this thesis we illustrate our findings via several simulations.

Thesis Supervisor: Kerem Ugurlu Title: Assistant Professor

(4)
(5)

Acknowledgments

This thesis is the last and most important work of my graduate degree in applied mathematics. I would like to thank my advisor, Kerem Ugurlu, for accompanying me from the beginning to the end of writing this thesis, giving advice and helping me understanding this area in mathematics. Also, I would like to especially thank Nazarbayev University for the opportunity to gain high knowledge by providing all the necessary conditions to obtain it.

(6)
(7)

Contents

1 Statistical Background 13

1.1 Random Variables . . . 13

1.1.1 Expected value(mean) and variance . . . 14

1.2 Common random variables . . . 15

1.2.1 Normal distribution . . . 15

1.2.2 Chi-square distribution . . . 15

1.2.3 Exponential distribution . . . 16

1.2.4 Student-t distribution . . . 17

1.2.5 Weibull distribution . . . 18

1.3 Verification of a Random Sample from a Distribution . . . 18

1.3.1 Kolmogorov-Smirnov Test . . . 18

1.3.2 Kolmogorov Smirnov test for 2 samples . . . 20

1.4 Linear Regression . . . 20

2 23 2.1 Risk measure . . . 23

2.2 Convex risk measures . . . 23

2.3 Coherent risk measures . . . 24

2.4 Value at Risk . . . 24

2.5 Average Value at Risk . . . 24

2.6 Tail conditional expectation . . . 27

2.7 Entropic risk measures . . . 28

(8)

3 29

3.1 Calculating AVaRโ€™s of different distributions . . . 29

3.2 Data . . . 30

3.3 Linear regression analysis . . . 31

3.4 Error analysis . . . 31

3.5 Calculating AVaRโ€™s from error . . . 32

A Code 39

(9)

List of Figures

1-1 Standard Normal Distribution . . . 15

1-2 Chi square distribution with different df . . . 16

1-3 Exponential distribution with different ๐œ† . . . 17

1-4 Student-t distribution with different degree of freedom . . . 17

1-5 Weibull distribution with different k and๐œ†=1 . . . 18

3-1 AVaRs of different distributions[Listing A.9] . . . 30

3-2 Real data . . . 30

3-3 Histogram of error[Listing A.4] . . . 31

3-4 QQ-plot of error[Listing A.7] . . . 32

3-5 AVaRs from error[Listing A.2] . . . 32

3-6 AVaRs and tail means[Listing A.8] . . . 33

3-7 AVaR(X) and -AVaR(-X)[Listing A.3] . . . 33

3-8 AVaR and Confidence levels[Listing A.5] . . . 34

3-9 Coherent risk measure and Entropic risk measure[Listing A.6] . . . . 35

3-10 AVaR and ERM with positive/negative signs[Listing A.10] . . . 35

(10)
(11)

Introduction

Expected performance criteria are used for solving optimization problems. Starting from Bellman, dynamic programming techniques have used risk neutral performance evaluation. Risk aversive methods have been started to used for prediction the cor- responding problems by utility functions because of not usefulness of the expected value to measure the criteria of the performance. Defining preferences of the risk- aversion into an axiomatic framework, by the paper of Artzner et al., then assessment of risks has a new side for random outcomes. Thus, coherent risk measure has been illustrated. The derivation of the dynamic programming equations of the risk-averse operations and measurement of risks is not so complicated in terms of it is not time- consuming. The reason behind this is that the Bellmann optimality principle is invalid to use in the operations in risk-averse problems. It is already known that the problem of stochastic decision in the multistage case takes more time. If the problem can be resolved at later steps, then there exist a solution for optimality on later stages. But this problem can be tackled by applying one-time Markovian dynamic risk measures.

Also, this difficulty can be solved with the application of state aggregation and AVaR decomposition theorem. In this approach, a dual representation of AVaR is used, and thus this method needs optimization over a probability space when finding a solution to the equation of Bellman. Specific sums of quantiles give AVaRs, which used to calculate any coherent risk measures. It visualised as table of numerical results of simulations with quantiles of different distributions.

(12)
(13)

Chapter 1

Statistical Background

1.1 Random Variables

Consider an experiment, where we throw a die 8 times and we count even outcome.

Then, we have sample spaceโ„ฆ,such that ๐‘ค0 ={๐ธ, ๐‘‚, ๐ธ, ๐ธ, ๐‘‚, ๐‘‚, ๐‘‚, ๐ธ} โˆˆโ„ฆ. In real, we are not interested about probability of coming outcome Even or Odd. We inter- ested on functions(real-valued) of outcomes, such as the number of Even outcomes that appear among our 8 tosses, or the length of the longest run of Odd outcomes.

These functions are called random variables.

Definition 1.1. Random variable X(w) is function X: โ„ฆโ†’R.

Suppose ๐‘‹(๐‘ค)is random variable of how many even outcome will be thrown in ๐‘ค trials. Given 8 experiments, so๐‘‹(๐‘ค)is finite number of values called discrete random variables. Here, the probability of the set associated with a random variable๐‘‹ taking on some specific value ๐‘˜ is

๐‘ƒ(๐‘‹ =๐‘˜) :=๐‘ƒ({๐‘ค:๐‘‹(๐‘ค) = ๐‘˜})

Now, we take random variable๐‘‹(๐‘ค)as decay time of Uranium. In this case,๐‘‹(๐‘ค)has infinite number of values, so it is called continuous random variables. We designate

(14)

probability that ๐‘‹ takes between two real values a and b:

๐‘ƒ(๐‘Žโ‰ค๐‘‹ โ‰ค๐‘) :=๐‘ƒ({๐‘ค:๐‘Ž โ‰ค๐‘‹(๐‘ค)โ‰ค๐‘})

1.1.1 Expected value(mean) and variance

Definition 1.2. For continuous random variables ๐‘‹ with range [๐‘Ž, ๐‘] and probability density function ๐‘“(๐‘ฅ) expected value is defined by integral:

E[๐‘‹] =

โˆซ๏ธ ๐‘ ๐‘Ž

๐‘ฅ๐‘“(๐‘ฅ)๐‘‘๐‘ฅ (1.1)

Definition 1.3. For discrete random variables ๐‘‹ expected value is weighted sum of values ๐‘ฅ๐‘–, where weights are probabilities ๐‘(๐‘ฅ๐‘–) :

E[๐‘‹] =

๐‘›

โˆ‘๏ธ

๐‘–=1

๐‘ฅ๐‘–๐‘(๐‘ฅ๐‘–) (1.2)

Also, expected value is called mean with symbol ๐œ‡. It has the following properties:

โˆ™ E[๐‘Ž] =๐‘Ž โˆ€๐‘Ž โˆˆR.

โˆ™ E[๐‘Ž๐‘‹+๐‘] =๐‘ŽE[๐‘‹] +๐‘ โˆ€๐‘Ž, ๐‘โˆˆR.

โˆ™ E[๐‘‹+๐‘Œ] =E[๐‘‹] +E[๐‘Œ]

Definition 1.4. Variance ๐œŽ2 is measure of concentration of distribution of random variables ๐‘‹ around its mean.

๐‘‰ ๐‘Ž๐‘Ÿ[๐‘‹] =E[(๐‘‹โˆ’E[๐‘‹])2] =E[๐‘‹2โˆ’2E[๐‘‹]๐‘‹+E[๐‘‹]2] =

=E[๐‘‹2]โˆ’2E[๐‘‹]E[๐‘‹] +E[๐‘‹]2 =E[๐‘‹2]โˆ’E[๐‘‹]2

(1.3)

Properties:

โˆ™ ๐‘‰ ๐‘Ž๐‘Ÿ[๐‘Ž] = 0 โˆ€๐‘ŽโˆˆR.

โˆ™ ๐‘‰ ๐‘Ž๐‘Ÿ[๐‘Ž๐‘‹+๐‘] =๐‘Ž2๐‘‰ ๐‘Ž๐‘Ÿ[๐‘‹] โˆ€๐‘Ž, ๐‘โˆˆR.

โˆ™ ๐‘‰ ๐‘Ž๐‘Ÿ[๐‘‹+๐‘Œ] =๐‘‰ ๐‘Ž๐‘Ÿ[๐‘‹] +๐‘‰ ๐‘Ž๐‘Ÿ[๐‘Œ]

(15)

Definition 1.5. Square root of variance is called standard deviation and denoted by ๐œŽ.

Definition 1.6. ๐‘๐‘กโ„Ž quantile of distribution ๐‘‹ is value such that ๐‘ƒ(๐‘‹ โ‰ค๐‘ž๐‘) = ๐‘

1.2 Common random variables

1.2.1 Normal distribution

Definition 1.7. A random variable ๐‘‹ is called normal distribution(Gausian distri- bution) if and only if, for ๐œŽ > 0 and -โˆž< ๐œ‡ <โˆž, its density function is:

๐‘“(๐‘ฅ) = 1 ๐œŽโˆš

2๐œ‹๐‘’โˆ’12(๐‘ฅโˆ’๐œ‡๐œŽ )2 (1.4)

Figure 1-1: Standard Normal Distribution

1.2.2 Chi-square distribution

Definition 1.8. The distribution which is generated by sum of squares of independent standard normal random variables ๐‘‹1, ๐‘‹2...๐‘‹๐‘› is called Chi-square distribution with degree of freedom k.

๐‘„=

๐‘˜

โˆ‘๏ธ

๐‘–=1

๐‘‹๐‘–๐‘˜

(16)

Probability density function of Chi-square distribution is :

๐‘“(๐‘ฅ, ๐‘˜) =

โŽง

โŽชโŽช

โŽจ

โŽชโŽช

โŽฉ

๐‘ฅ๐‘˜2โˆ’1๐‘’โˆ’๐‘ฅ2

2๐‘˜2ฮ“(๐‘˜2) , ๐‘ฅ >0;

0, ๐‘œ๐‘กโ„Ž๐‘’๐‘Ÿ๐‘ค๐‘–๐‘ ๐‘’.

(1.5)

where ฮ“ is gamma function.

Figure 1-2: Chi square distribution with different df

1.2.3 Exponential distribution

Definition 1.9. Exponential distribution with๐œ† >0 is random variable X with density function of X:

๐‘“(๐‘ฅ, ๐œ†) =

โŽง

โŽชโŽจ

โŽชโŽฉ

๐œ†๐‘’โˆ’๐œ†๐‘ฅ, ๐‘ฅโ‰ฅ0;

0, ๐‘ฅ <0.

(1.6)

(17)

Figure 1-3: Exponential distribution with different๐œ†

1.2.4 Student-t distribution

Definition 1.10. Student-t distribution๐‘‹ is random variable with probability density function of ๐‘‹:

๐‘“(๐‘ฅ, ๐œˆ) = ฮ“(๐œˆ+12 )

โˆš๐œˆ๐œ‹ฮ“(๐œˆ2) (๏ธƒ

1 + ๐‘ฅ2 ๐œˆ

)๏ธƒโˆ’๐œˆ+1

2

(1.7) where ๐œˆ >0 is degree of freedom.

Figure 1-4: Student-t distribution with different degree of freedom

(18)

1.2.5 Weibull distribution

Definition 1.11. Weibull distribution ๐‘‹ is random variable with probability density function of ๐‘‹:

๐‘“(๐‘ฅ, ๐œ†, ๐‘˜) =

โŽง

โŽชโŽจ

โŽชโŽฉ

๐‘˜

๐œ†(๐‘ฅ๐œ†)๐‘˜โˆ’1๐‘’(โˆ’๐‘ฅ๐œ†)๐‘˜, ๐‘ฅโ‰ฅ0;

0, ๐‘ฅ < 0.

(1.8)

where ๐‘˜ >0 is shape parameter and ๐œ† >0 is scale parameter.

Figure 1-5: Weibull distribution with different k and ๐œ†=1

1.3 Verification of a Random Sample from a Distri- bution

1.3.1 Kolmogorov-Smirnov Test

Suppose that we have an i.i.d. sample๐‘‹1, ๐‘‹2, ..., ๐‘‹๐‘› with some unknown distribution Pand we would like to test the hypothesis thatPis equal to a particular distribution P0 i.e. decide between the following hypotheses:

๐ป0 :P=P0, ๐ป1 :Pฬธ=P0

(19)

Kolmogorov-Smirnov test is a non-parametric test used for testing a hypothesis๐‘‹1, ๐‘‹2...๐‘‹๐‘› have a given continuous distribution function ๐น, against the one-sided alternative ๐ป1+ : sup|๐œ’|<โˆž(๐ธ๐น๐‘›(๐‘ฅ))โˆ’๐น(๐‘ฅ))>0, where ๐ธ๐น๐‘› is the mathematical expectation of the empirical distribution function ๐น๐‘›. The Kolmogorovโ€“Smirnov test is constructed from the statistic:

๐ท+๐‘› = sup

|๐œ’|<โˆž

(๐น๐‘›(๐‘ฅ))โˆ’๐น(๐‘ฅ)) = max

1โ‰ค๐‘šโ‰ค๐‘›(๐‘š

๐‘› โˆ’๐น(๐‘‹(๐‘š)))

where ๐‘‹(1)...๐‘‹(๐‘›) is the variational series (or set of order statistics) obtained from the sample ๐‘‹1, ๐‘‹2...๐‘‹๐‘›. Thus, the Kolmogorovโ€“Smirnov test is a variant of the Kolmogorov test for testing the hypothesis ๐ป0 against a one-sided alternative ๐ป1+. By studying the distribution of the statistic ๐ท+๐‘›, N.V. Smirnov showed that

๐‘ƒ{๐ท๐‘›+โ‰ฅ๐œ†}=

(1โˆ’๐œ†)๐‘›

โˆ‘๏ธ

๐‘˜=1

๐œ†(๏ธ€๐‘›

๐‘˜

)๏ธ€(๐œ†+ ๐‘˜

๐‘›)๐‘˜โˆ’1(1โˆ’๐œ†โˆ’ ๐‘˜ ๐‘›)๐‘›โˆ’๐‘˜,

where 0 < ๐œ† <1 and [๐›ผ] is integer part of number ๐›ผ. Smirnov obtained in addition to the exact distribution of๐ท๐‘› its limit distribution, namely: if๐‘›โ†’ โˆžand 0< ๐œ†0 <

๐œ†=๐‘‚(๐‘›16),

๐‘ƒ{๐ท๐‘›+โ‰ฅ๐œ†}=๐‘’โˆ’2๐œ†2[๏ธ

1 +๐‘‚(๏ธ 1

โˆš๐‘› )๏ธ]๏ธ

,

where ๐œ†0 is any positive number. By means of the technique of asymptotic Pearson transformation it has been proved that if ๐‘› โ†’ โˆžand 0< ๐œ†0 < ๐œ†=๐‘‚(๐‘›13), then

๐‘ƒ{ 1

18๐‘›(6๐‘›๐ท+๐‘› + 1)2 โ‰ฅ๐œ†}=๐‘’โˆ’๐œ†[๏ธ

1 +๐‘‚(๏ธ1 ๐‘›

)๏ธ]๏ธ

.

According to the Kolmogorovโ€“Smirnov test, the hypothesis๐ป0 must be rejected with significance level ๐›ผ whenever

๐‘’๐‘ฅ๐‘[๏ธ 1

18๐‘›(6๐‘›๐ท+๐‘› + 1)2]๏ธ

โ‰ค๐›ผ,

(20)

where,

๐‘ƒ{๏ธ

๐‘’๐‘ฅ๐‘[๏ธ 1

18๐‘›(6๐‘›๐ท+๐‘› + 1)2]๏ธ

โ‰ค๐›ผ}๏ธ

=๐›ผ[๏ธ

1 +๐‘‚(๏ธ1 ๐‘›

)๏ธ]๏ธ

.

The testing of ๐ป0 against the alternative ๐ป0โˆ’: inf|๐œ’|<โˆž(๐ธ๐น๐‘›(๐‘ฅ))โˆ’๐น(๐‘ฅ))<0 is dealt with similarly. In this case the statistic of the Kolmogorovโ€“Smirnov test is the random variable

๐ท๐‘›โˆ’=โˆ’ inf

|๐œ’|<โˆž(๐น๐‘›(๐‘ฅ))โˆ’๐น(๐‘ฅ)) = max

1โ‰ค๐‘šโ‰ค๐‘›(โˆ’๐‘šโˆ’1

๐‘› +๐น(๐‘‹(๐‘š))) whose distribution is the same as that of the statistic ๐ท๐‘›+ when ๐ป0 is true.

1.3.2 Kolmogorov Smirnov test for 2 samples

KS test for 2 sample is similar to KS test. Suppose we have first sample size of ๐‘š with c.d.f ๐น(๐‘ฅ) and second sample with size๐‘› with c.d.f๐บ(๐‘ฅ) and we want to test:

๐ป0 :๐น =๐บ ๐‘ฃ๐‘  ๐ป1 :๐น ฬธ=๐บ

If ๐น๐‘š(๐‘ฅ)and ๐บ๐‘› are corresponding empirical c.d.f.s then the statistic ๐ท๐‘š๐‘› =(๏ธ€ ๐‘š๐‘›

๐‘š+๐‘› )๏ธ€12

sup

๐‘ฅ

|๐น๐‘š(๐‘ฅ)โˆ’๐บ๐‘›(๐‘ฅ)|

and other are same.

1.4 Linear Regression

In statistics, linear regression is a linear approach to modeling the relationship be- tween a scalar response (or dependent variable) and one or more explanatory variables (or independent variables). The case of one explanatory variable is called simple linear regression.

๐‘ฆโ‰ˆ๐‘ฆห†=๐‘‹๐‘ค

(21)

As loss function we take sum of squared errors:

๐ฟ(๐‘ค) =

๐‘›

โˆ‘๏ธ

๐‘›=1

(๐‘ฅ๐‘‡๐‘– ๐‘คโˆ’๐‘ฆ๐‘–)2 =๐‘š๐‘–๐‘›๐‘ค||๐‘‹๐‘คโˆ’๐‘ฆ||ห† 22

๐‘ค* =๐‘Ž๐‘Ÿ๐‘”๐‘š๐‘–๐‘›๐‘ค๐ฟ(๐‘ค) = (๏ธ€

๐‘‹๐‘‡๐‘‹)โˆ’1๐‘‹๐‘‡๐‘ฆ

Proof: Now, we can find the smallest ๐‘ค by minimizing loss function.

๐ฟ(๐‘ค) =

๐‘›

โˆ‘๏ธ

๐‘›=1

(๐‘ฅ๐‘‡๐‘– ๐‘คโˆ’๐‘ฆ๐‘–)2 =๐‘š๐‘–๐‘›๐‘ค||๐‘‹๐‘คโˆ’๐‘ฆ||ห† 22

= (๐‘‹๐‘คโˆ’๐‘ฆ)๐‘‡(๐‘‹๐‘คโˆ’๐‘ฆ)

= (๐‘‹๐‘ค)๐‘‡๐‘‹๐‘คโˆ’(๐‘‹๐‘ค)๐‘‡๐‘ฆโˆ’๐‘ฆ๐‘‡๐‘‹๐‘ค+๐‘ฆ๐‘‡๐‘ฆ

=๐‘ค๐‘‡๐‘‹๐‘‡๐‘‹๐‘คโˆ’2๐‘ค๐‘‡๐‘‹๐‘‡๐‘ฆ+๐‘ฆ๐‘‡๐‘ฆ We take gradient of ๐ฟ(๐‘ค) and equate to 0:

โˆ‡๐ฟ(๐‘ค) =โˆ‡(๐‘ค๐‘‡๐‘‹๐‘‡๐‘‹๐‘คโˆ’2๐‘ค๐‘‡๐‘‹๐‘‡๐‘ฆ+๐‘ฆ๐‘‡๐‘ฆ)

=โˆ‡(๐‘ค๐‘‡๐‘‹๐‘‡๐‘‹๐‘ค)โˆ’2โˆ‡(๐‘ค๐‘‡๐‘‹๐‘‡๐‘ฆ) +โˆ‡(๐‘ฆ๐‘‡๐‘ฆ)

= 2๐‘‹๐‘‡๐‘‹๐‘คโˆ’2๐‘‹๐‘‡๐‘ฆ= 0 ๐‘ค* =๐‘Ž๐‘Ÿ๐‘”๐‘š๐‘–๐‘›๐‘ค๐ฟ(๐‘ค) =(๏ธ€

๐‘‹๐‘‡๐‘‹)โˆ’1๐‘‹๐‘‡๐‘ฆ

(22)
(23)

Chapter 2

We refer the reader for the definitions and theorems of this chapter and for further study of risk measures to [5].

2.1 Risk measure

Definition 2.1. A risk measure ๐œŒ is a function from random variables to real num- bers: ๐œŒ:๐‘‹ โ†’R.

Properties:

โˆ™ ๐œŒ(0) = 0

โˆ™ ๐œŒ(๐‘‹+๐‘Ž) =๐œŒ(๐‘‹) +๐‘Ž for โˆ€๐‘ŽโˆˆR

โˆ™ if ๐‘‹1 โ‰ค๐‘‹2 then ๐œŒ(๐‘‹1)โ‰ค๐œŒ(๐‘‹2) for โˆ€๐‘‹1, ๐‘‹2 โˆˆ๐‘‹

2.2 Convex risk measures

Definition 2.2. Consider a probability space(โ„ฆ,โ„ฑ,P)and the space๐’ต :=๐ฟ1(โ„ฆ,โ„ฑ,P) of measurable functions ๐‘ : โ„ฆ โ†’ R (random variables) that have finite first order moments, i.e. EP[|๐‘|] < โˆž, where E[ยท] means the expectation with respect to the probability measure P. A mapping ๐œŒ: ๐’ต โ†’R is called a convex risk measure, if the following axioms hold:

โˆ™ (A1)(Convexity)๐œŒ(๐œ†๐‘‹+ (1โˆ’๐œ†)๐‘Œ)โ‰ค๐œ†๐œŒ(๐‘‹) + (1โˆ’๐œ†)๐œŒ(๐‘Œ)โˆ€๐œ†โˆˆ(0,1), ๐‘‹, ๐‘Œ โˆˆ ๐’ต

(24)

โˆ™ (A2)(Monotonicity) If๐‘‹ โ‰ค๐‘Œ, then๐œŒ(๐‘‹)โ‰ค๐œŒ(๐‘Œ),โˆ€๐‘‹, ๐‘Œ โˆˆ ๐’ต

โˆ™ (A3)(Translation Invariance)๐œŒ(๐‘+๐‘‹) =๐‘+๐œŒ(๐‘‹),โˆ€๐‘โˆˆR, ๐‘‹โˆˆ ๐’ต

2.3 Coherent risk measures

Definition 2.3. Consider a probability space(โ„ฆ,โ„ฑ,P)and the space๐’ต :=๐ฟ1(โ„ฆ,โ„ฑ,P) of measurable functions ๐‘ : โ„ฆ โ†’ R (random variables) that have finite first order moments, i.e. EP[|๐‘|] < โˆž, where E[ยท] means the expectation with respect to the probability measure P. A mapping ๐œŒ : ๐’ต โ†’ R is said to be called a coherent risk measure, if the following axioms hold:

โˆ™ (A1)(Convexity)๐œŒ(๐œ†๐‘‹+ (1โˆ’๐œ†)๐‘Œ)โ‰ค๐œ†๐œŒ(๐‘‹) + (1โˆ’๐œ†)๐œŒ(๐‘Œ)โˆ€๐œ†โˆˆ(0,1), ๐‘‹, ๐‘Œ โˆˆ ๐’ต

โˆ™ (A2)(Monotonicity) If๐‘‹ โ‰ค๐‘Œ, then๐œŒ(๐‘‹)โ‰ค๐œŒ(๐‘Œ),โˆ€๐‘‹, ๐‘Œ โˆˆ ๐’ต

โˆ™ (A3)(Translation Invariance)๐œŒ(๐‘+๐‘‹) =๐‘+๐œŒ(๐‘‹),โˆ€๐‘โˆˆR, ๐‘‹โˆˆ ๐’ต

โˆ™ (A4)(Homogeneity)๐œŒ(๐›ฝ๐‘‹) =๐›ฝ๐œŒ(๐‘‹), ๐‘‹โˆˆ ๐’ต, ๐›ฝโ‰ฅ0

2.4 Value at Risk

Definition 2.4. Let (โ„ฆ,๐’ข,P) be a measurable space and let ๐‘‹ โˆˆ ๐ฟ1(โ„ฆ,๐’ข,P) be a real-valued random variable and ๐›ผ โˆˆ(0,1).Then VaR is:

๐‘‰ ๐‘Ž๐‘…๐›ผ(๐‘‹) =๐‘–๐‘›๐‘“{๐‘ฅโˆˆR:P(๐‘‹ โ‰ค๐‘ฅ)โ‰ฅ๐›ผ} (2.1) But ๐‘‰ ๐‘Ž๐‘… is not coherent risk measure. So we will use Average Value at Risk.

2.5 Average Value at Risk

Definition 2.5. Let (โ„ฆ,๐’ข,P) be a measurable space and let ๐‘‹ โˆˆ ๐ฟ1(โ„ฆ,๐’ข,P) be a real-valued random variable and ๐›ผ โˆˆ(0,1).Then AVaR is:

๐ด๐‘‰ ๐‘Ž๐‘…๐›ผ(๐‘‹) = 1 1โˆ’๐›ผ

โˆซ๏ธ 1 ๐›ผ

๐‘‰ ๐‘Ž๐‘…๐‘ก(๐‘‹)๐‘‘๐‘ก (2.2)

(25)

Definition 2.6. Suppose ๐›ฟ is probability measure on R and ๐›ผโˆˆ(0,1).

โˆ™ A number ๐‘žโˆˆR is called ๐›ผ-quantile of ๐›ฟ if:

๐›ฟ((โˆ’โˆž, ๐‘ž])โ‰ฅ๐›ผ ๐‘Ž๐‘›๐‘‘ ๐›ฟ(([๐‘ž,โˆž))โ‰ฅ1โˆ’๐›ผ. (2.3)

โˆ™ A function๐‘ž๐›ฟ: (0,1)โ†’Ris called a quantile function of ๐›ฟif for each๐›ผ โˆˆ(0,1), ๐‘ž๐›ฟ(๐›ผ) is an ๐›ผ-quantile of ๐›ฟ.

Remark:

1.The set of ๐›ผ-quantile of ๐›ฟ is a non-empty bounded closed interval and end points are ๐‘ž๐›ฟโˆ’(๐›ผ) and ๐‘ž๐›ฟ+(๐›ผ).

2.The set {๐›ผโˆˆ (0,1) | ๐‘ž๐›ฟโˆ’ < ๐‘ž+๐›ฟ} is countable. Because ๐›ผ-s for which ๐‘ž๐›ฟโˆ’(๐›ผ)< ๐‘ž+๐›ฟ(๐›ผ) corresponds to intervals of constancy of the cumulative distribution function of๐›ฟ.

Theorem 2.5.1. If ๐‘‹ โˆˆ๐ฟ1(โ„ฆ,๐’ข,P) and ๐›ผ โˆˆ(0,1), then there exists an integral

โˆซ๏ธ 1 0

๐‘‰ ๐‘Ž๐‘…๐›ผ๐‘‘๐›ผ

and it is equal to E[๐‘‹].

Proof:

โˆซ๏ธ 1 0

๐‘‰ ๐‘Ž๐‘…๐›ผ๐‘‘๐›ผ =

โˆซ๏ธ 1 0

๐‘ž๐›ฟโˆ’(๐›ผ) =E[๐‘žโˆ’๐›ฟ(๐›ผ)] =E[๐‘‹]

Theorem 2.5.2. Suppose ๐‘ž๐‘‹ is quantile function for distribution ๐‘‹. Then

๐ด๐‘‰ ๐‘Ž๐‘…๐œ†(๐‘‹) = 1

๐œ†E[(๐‘‹โˆ’๐‘ž๐‘‹(๐œ†))+] +๐‘ž๐‘‹(๐œ†). (2.4) Proof: Suppose๐‘ˆ is standard uniform random variable. Then distributions of๐‘‹

(26)

and ๐‘ž๐‘‹(๐‘ˆ)are same. And consequently:

1

๐œ†E[(๐‘‹โˆ’๐‘ž๐‘‹(๐œ†))+] +๐‘ž๐‘‹(๐œ†)

=1

๐œ†E[(๐‘ž๐‘‹(๐‘ˆ)โˆ’๐‘ž๐‘‹(๐œ†))+] +๐‘ž๐‘‹(๐œ†)

=1 ๐œ†

โˆซ๏ธ 1 0

(๐‘ž๐‘‹(๐›ผ)โˆ’๐‘ž๐‘‹(๐œ†))+๐‘‘๐›ผ+๐‘ž๐‘‹(๐œ†)

=1 ๐œ†

โˆซ๏ธ 1 1โˆ’๐œ†

(๐‘ž๐‘‹(๐›ผ)โˆ’๐‘ž๐‘‹(๐œ†))๐‘‘๐›ผ+๐‘ž๐‘‹(๐œ†)

=1 ๐œ†

โˆซ๏ธ 1 1โˆ’๐œ†

๐‘‰ ๐‘Ž๐‘…๐›ผ(๐‘‹)๐‘‘๐›ผ

=AVaR๐œ†(๐‘‹)

(2.5)

Theorem 2.5.3.

AVaR๐œ†(๐‘‹) = sup {๏ธ

EQ[๐‘‹]

โƒ’

โƒ’

โƒ’ Qโ‰ชP,๐‘‘๐‘„

๐‘‘P โ‰ค 1 1โˆ’๐œ†

}๏ธ

. (2.6)

Proof: The supremum on the right-hand side is equal to

sup{๏ธ€

E[๐œ™๐‘‹]โƒ’

โƒ’๐œ™โˆˆ โ„’1(โ„ฆ,โ„ฑ,P),E[๐œ™] = 1,0โ‰ค๐œ™โ‰ค 1 1โˆ’๐œ†

}๏ธ

E[๐œ™๐‘‹] is large, if ๐œ™ takes large values at points, where ๐‘‹ takes large values. Hence the supremum is attained for

๐œ™:=

โŽง

โŽชโŽช

โŽชโŽช

โŽชโŽจ

โŽชโŽช

โŽชโŽช

โŽชโŽฉ

1/1โˆ’๐œ† on{๐‘‹ > ๐‘ž๐‘‹(๐œ†)}, 0 on{๐‘‹ < ๐‘ž๐‘‹(๐œ†)}, ๐‘˜ on{๐‘‹ =๐‘ž๐‘‹(๐œ†)}.

where๐‘ž๐‘‹ is any quantile function of the distribution of๐‘‹and๐‘˜ is such thatE[๐œ™] = 1, i.e.

1

1โˆ’๐œ†P(๐‘‹ > ๐‘ž๐‘‹(๐œ†)) +๐‘˜P(๐‘‹ =๐‘ž๐‘‹(๐œ†)) = 1.

(27)

it follows that

sup{๏ธ

E[๐œ™๐‘‹]

โƒ’

โƒ’

โƒ’๐œ™โˆˆ โ„’1(โ„ฆ,โ„ฑ,P),E[๐œ™] = 1, 0โ‰ค๐œ™โ‰ค 1 1โˆ’๐œ†

}๏ธ

= 1

1โˆ’๐œ†E[๐‘‹ยท1{๐‘‹>๐‘ž๐‘‹(๐œ†)}] +๐‘˜E[๐‘‹ยท1{๐‘‹=๐‘ž+(๐œ†)}]

=AVaR๐œ†(๐‘‹).

2.6 Tail conditional expectation

Tail conditional expectation is used to measure market and non-market risks, pre- sumably for a portfolio of investments. It gives a measure of a right-tail risk, one with which actuaries are very familiar because insurance contracts typically possess exposures subject to โ€œlow-frequency but large-lossesโ€.

Definition 2.7. For ๐œ†โˆˆ(0,1) tail conditional expectation is defined by:

๐‘‡ ๐ถ๐ธ๐œ†(๐‘‹) :=E[๐‘‹|๐‘‹ โ‰ฅ๐‘‰ ๐‘Ž๐‘…๐œ†(๐‘‹)] (2.7)

Theorem 2.6.1. For ๐œ† โˆˆ (0,1) ๐‘‡ ๐ถ๐ธ๐œ†(๐‘‹) and ๐ด๐‘‰ ๐‘Ž๐‘…๐œ†(๐‘‹) are equal if and only if P(๐‘‹ โ‰ฅ๐‘‰ ๐‘Ž๐‘…๐œ†(๐‘‹)) = 1โˆ’๐œ†. It happens if and only if๐‘‹ has continuous distribution.

Proof:

Suppose P(๐‘‹ โ‰ฅ๐‘‰ ๐‘Ž๐‘…๐œ†(๐‘‹)) =๐œ†. Then:

๐‘‡ ๐ถ๐ธ๐œ†(๐‘‹) =E[๐‘‹ยท1{๐‘‹โ‰ฅ๐‘‰ ๐‘Ž๐‘…๐œ†(๐‘‹)}] P(๐‘‹ โ‰ฅ๐‘‰ ๐‘Ž๐‘…๐œ†(๐‘‹))

= 1

1โˆ’๐œ†E[๐‘‹ยท1{๐‘‹โ‰ฅ๐‘‰ ๐‘Ž๐‘…๐œ†(๐‘‹)}]

= 1

1โˆ’๐œ†E[(๐‘‹โˆ’๐‘‰ ๐‘Ž๐‘…๐œ†(๐‘‹))ยท1{๐‘‹โ‰ฅ๐‘‰ ๐‘Ž๐‘…๐œ†(๐‘‹)}] +๐‘‰ ๐‘Ž๐‘…๐œ†(๐‘‹)

= 1

1โˆ’๐œ†E[(๐‘‹โˆ’๐‘‰ ๐‘Ž๐‘…๐œ†(๐‘‹))+] +๐‘‰ ๐‘Ž๐‘…๐œ†(๐‘‹) =๐ด๐‘‰ ๐‘Ž๐‘…๐œ†(๐‘‹)

(2.8)

(28)

2.7 Entropic risk measures

In financial mathematics, the entropic risk measure is a risk measure which depends on the risk aversion of the user through the exponential utility function.

Definition 2.8. The entropic risk measure with the risk aversion parameter ๐œƒ >0is defined as :

๐œŒ๐‘’๐‘›๐‘ก(๐‘‹) = 1

๐œƒ๐‘™๐‘œ๐‘”(E[๐‘’๐œƒ๐‘‹]) = sup{๏ธ

E๐‘„[๐‘‹]โˆ’ 1

๐œƒ๐ป(๐‘„|P)}๏ธ

(2.9) If X has standard normal distribution, then

1

๐œƒlog(E[๐‘’๐œƒ๐‘‹]) =1

๐œƒlog( 1

โˆš2๐œ‹๐œŽ

โˆซ๏ธ โˆž

โˆ’โˆž

๐‘’๐œƒ๐‘ฅ๐‘’โˆ’๐‘ฅ

2 2๐œŽ2 ๐‘‘๐‘ฅ)

=1

๐œƒlog( 1

โˆš2๐œ‹๐œŽ

โˆซ๏ธ โˆž

โˆ’โˆž

๐‘’๐œƒ

2๐œŽ2 2 โˆ’(โˆš๐‘ฅ

2๐œŽโˆ’โˆš๐œƒ๐œŽ

2)2

๐‘‘๐‘ฅ)

โƒ’

โƒ’

โƒ’๐‘ข= ๐‘ฅโˆ’๐œƒ๐œŽ2

โˆš2๐œŽ โ†’ ๐‘‘๐‘ข

๐‘‘๐‘ฅ = 1

โˆš2๐œ‹๐œŽ

โƒ’

โƒ’

โƒ’

=1

๐œƒlog( 1

โˆš2๐œ‹๐œŽ

โˆซ๏ธ โˆž

โˆ’โˆž

โˆš 2๐œŽ๐‘’๐œƒ

2๐œŽ2 2 โˆ’๐‘ข

๐‘‘๐‘ข)

=1 ๐œƒlog(๐‘’๐œƒ

2๐œŽ2 2

โˆซ๏ธ โˆž

โˆ’โˆž

โˆš1

๐œ‹๐‘’โˆ’๐‘ข ๐‘‘๐‘ข) = 1 ๐œƒlog(๐‘’๐œƒ

2๐œŽ2

2 ๐‘’๐‘Ÿ๐‘“(โˆž)) = ๐œƒ๐œŽ2 2

(29)

Chapter 3

3.1 Calculating AVaRโ€™s of different distributions

We calculate AVaRโ€™s of common distributions by the formula (2.2) and present their graphs with respect to different๐›ผ values.

(30)

Figure 3-1: AVaRs of different distributions[Listing A.9]

3.2 Data

We use the data from 18.12.2019 to 19.12.2018 (https://http//investfunds.kz). It contains exchange rate value of USD/KZT and main factors affecting on it (BRENT price and USD/RUR exchange rate value).

Figure 3-2: Real data

(31)

3.3 Linear regression analysis

We do linear regression to all our data. Then we predict new Y by given X values of our data. After we calculate error by subtracting exact value from predicted value.

3.4 Error analysis

From error we calculate sample mean and sample standard deviation. To define dis- tribution of error we do Kolmogorov-Smirnov test with different distributions with same mean and standard deviation as in our error. It gives p-value equal to 0.52 with Normal distribution. Then we do histogram and qq-plot of our error :

Figure 3-3: Histogram of error[Listing A.4]

It looks very similar to normal distribution.But we can see some values are not normal because plot is not exactly bell shaped.

Then, to dispel doubts, we draw qq-plot. As qq-plot is scatter plot which is plotted as one set of quantiles against second, we plot qq-plot our error against normal dis- tribution with same mean and variance. Here we can see that most of the values are normal but in right and left sides some amount of values not normal.

(32)

Figure 3-4: QQ-plot of error[Listing A.7]

3.5 Calculating AVaRโ€™s from error

Then we calculate AVaRโ€™s by definition, for VaR we use quantiles of normal distribu- tion with equal mean and standard deviation with mean and standard deviation of our error. We plot bars to show amounts of AVaR at every value ๐›ผ.

Figure 3-5: AVaRs from error[Listing A.2]

Figure shows that by rising of ๐›ผ values AVaR is rising too. Because by formula of AVaR, AVaR is inverse proportional to ๐›ผ. Then we calculate mean from last tail mean of our error such as last 10 percent then last 20 percent of our error until whole

(33)

data and sort them to plot with our AVaRs. We do it to compare sorted tail means of error with AVaRs. As shown in figure itโ€™s less than AVaR but after ๐›ผ = 0.5 this value become bigger than AVaR.

Figure 3-6: AVaRs and tail means[Listing A.8]

Then we calculateโˆ’๐ด๐‘‰ ๐‘Ž๐‘…(โˆ’๐‘‹)asโˆ’๐‘‹from error(๐‘’๐‘ฅ๐‘Ž๐‘๐‘กโˆ’๐‘๐‘Ÿ๐‘’๐‘‘๐‘–๐‘๐‘ก๐‘’๐‘‘) and we see that ๐ด๐‘‰ ๐‘Ž๐‘…(๐‘‹) and โˆ’๐ด๐‘‰ ๐‘Ž๐‘…(โˆ’๐‘‹) are symmetric. We do it to use AVaRs as confidence level in statistics.

Figure 3-7: AVaR(X) and -AVaR(-X)[Listing A.3]

(34)

Then we compare our ๐ด๐‘‰ ๐‘Ž๐‘…(๐‘‹)and โˆ’๐ด๐‘‰ ๐‘Ž๐‘…(โˆ’๐‘‹)values with confidence level and make plot :

Figure 3-8: AVaR and Confidence levels[Listing A.5]

We plot๐ด๐‘‰ ๐‘Ž๐‘…โ€ฒ๐‘ by๐›ผvalues and confidence levels by percents. We can compare them because for positive๐ด๐‘‰ ๐‘Ž๐‘…,โˆ’๐ด๐‘‰ ๐‘Ž๐‘…is negative values, at that time, confidence levels took negative values until 50 percent and then they become positive .

Then we compare coherent risk measure with entropic risk measure to show which will give more better. We calculate entropic risk measure with formula

๐œŒ๐‘’๐‘›๐‘ก(๐‘‹) = 1

๐œƒ๐‘™๐‘œ๐‘”(E[๐‘’๐œƒ๐‘‹]) = sup{๏ธ

E๐‘„[๐‘‹]โˆ’ 1

๐œƒ๐ป(๐‘„|P)}๏ธ

Figure is done for equal ๐œƒ โˆ’๐›ผ values to compare them, and we see ๐ด๐‘‰ ๐‘Ž๐‘… value is greater than entropic risk measure value only when ๐œƒ โˆ’๐›ผ = 0.1 and ๐œƒโˆ’๐›ผ = 0.9.

Then we compare๐ด๐‘‰ ๐‘Ž๐‘…(๐‘‹)andโˆ’๐ด๐‘‰ ๐‘Ž๐‘…(โˆ’๐‘‹)with๐ธ๐‘…๐‘€(๐‘‹)andโˆ’๐ธ๐‘…๐‘€(โˆ’๐‘‹)to show how it will be for uses as confidence level.

(35)

Figure 3-9: Coherent risk measure and Entropic risk measure[Listing A.6]

Figure 3-10: AVaR and ERM with positive/negative signs[Listing A.10]

(36)
(37)

Conclusion

The main purpose of this thesis is make prediction by risk measures. Main tool was coherent risk measure - AVaR. To achieve this,first we collected data of USD/KZT and main affecting factors from investfunds.kz and did linear regression analysis.

Second, we calculated sample mean and sample standard deviation of prediction errors. Using Kolmogorov-Smirnov test, we concluded that errors are coming from normal distribuiton. Third, we calulated AVaRโ€™s and negative values of AVaRโ€™s to plot them with confidence levels. As confidence levels, AVaRโ€™s with different๐›ผvalues gave best intervals for errors. Every interval between AVaR and minus AVaR with different ๐›ผ values contains ๐›ผ*10 percent of errors. We also used entropic risk measure instead of AVaR and ploted AVaR confidence levels and entropic risk measure confidence levels.

(38)
(39)

Appendix A Code

1 i m p o r t n u m p y as np

2 f r o m s c i p y . s t a t s i m p o r t c h i2

3 i m p o r t m a t p l o t l i b . p y p l o t as plt

4 i m p o r t s c i p y

5 i m p o r t p a n d a s as pd

6 f r o m s k l e a r n . l i n e a r _ m o d e l i m p o r t L i n e a r R e g r e s s i o n

7 i m p o r t m a t h

8 i m p o r t r a n d o m

9 f r o m s c i p y . s t a t s i m p o r t n o rm

10 f r o m s c i p y . s t a t s i m p o r t c h i2

11 f r o m s c i p y . s t a t s i m p o r t w e i b u l l _ m i n

12 i m p o r t s e a b o r n as sns

13 i m p o r t s c i p y . i n t e g r a t e as i n t e g r a t e

14 f r o m s t a t s m o d e l s . g r a p h i c s . g o f p l o t s i m p o r t q q p l o t _ 2 s a m p l e s

15 df = pd . r e a d _ e x c e l (โ€™ d a t a . xls โ€™)

16 y_1 = df [โ€™ kzt โ€™]

17 y _ e x a c t _ 1 = np . a r r a y ( y_1 )

18 x_1 = df [[โ€™ b r e n t โ€™,โ€™ rur โ€™]]

19 r e g _ 1 = L i n e a r R e g r e s s i o n () . fit ( x_1 , y_1 )

20 y _ p r e d _ 1 = r e g _ 1 . p r e d i c t ( x_1 )

21 e r r o r _ 1 = np . a r r a y ( y _ p r e d _ 1 - y _ e x a c t _ 1 )

22 s t d _ 1 = np . std ( e r r o r _ 1 )

23 m e a n _ 1 = np . m e an ( e r r o r _ 1 )

24 def V a r N o r m ( alpha , mean , s t d d e v ) :

(40)

25 s = s c i p y . s t a t s . n or m . ppf ( alpha , mean , s t d d e v )

26 r e t u r n s

27 def A V a R ( k , mean , std ) :

28 r e s u l t = (1/ (1 - k ) ) *f l o a t( i n t e g r a t e . q u a d (l a m b d a x : V a r N o r m ( x , mean , std ) , k ,1) [ 0 ] )

29 r e t u r n r e s u l t

Listing A.1: AVAR

1 X = np . a r a n g e (0 ,1 ,0.1)

2 d a t a _ a v a r = [[ A V a R (0 , mean_1 , s t d _ 1 ) , A V a R (0.1 , mean_1 , s t d _ 1 ) , A Va R (0.2 , mean_1 , s t d _ 1 ) , A V a R (0.3 , mean_1 , s t d _ 1 ) , A V a R (0.4 , mean_1 , s t d _ 1 ) , A V a R (0.5 , mean_1 , s t d _ 1 ) , A V a R (0.6 , mean_1 , s t d _ 1 ) , A V a R (0.7 , mean_1 , s t d _ 1 ) , A V a R (0.8 , mean_1 , s t d _ 1 ) , A V a R (0.9 , mean_1 , s t d _ 1 ) ]]

3

4

5 plt . bar ( X , d a t a _ a v a r [0] , c o l o r = โ€™ red โ€™, w i d t h = 0 . 0 5 )

6

7 c o l o r s = {โ€™ A V a R โ€™:โ€™ red โ€™}

8 l a b e l s = l i s t( c o l o r s . k e y s () )

9 h a n d l e s = [ plt . R e c t a n g l e ((0 ,0) ,1 ,1 , c o l o r = c o l o r s [ l a b e l ]) for l a b e l in l a b e l s ]

10 plt . l e g e n d ( handles , l a b e l s )

11 plt . x l a b e l (โ€™ A l p h a โ€™)

12 plt . y l a b e l (โ€™ A V a R โ€™)

13 plt . t i t l e (โ€™ A V a R w h o l e d a t a โ€™ )

Listing A.2: Calculation of AVaR

1 e r r o r _ 2 = np . a r r a y ( y _ e x a c t _ 1 - y _ p r e d _ 1 )

2 s t d _ 2 = np . std ( e r r o r _ 2 )

3 m e a n _ 2 = np . m e an ( e r r o r _ 2 )

4

5

6 X = np . a r a n g e (10

7 )

8 d a t a = -1 * np . a r r a y ([[ AV a R (0 , mean_2 , s t d _ 2 ) , A Va R (0.1 , mean_2 , s t d _ 2 ) , A V a R (0.2 , mean_2 , s t d _ 2 ) ,

(41)

9 A V a R (0.3 , mean_2 , s t d _ 2 ) , A V a R (0.4 , mean_2 , s t d _ 2 ) , A V aR (0.5 , mean_2 , s t d _ 2 ) ,

10 A V a R (0.6 , mean_2 , s t d _ 2 ) ,

11 A V a R (0.7 , mean_2 , s t d _ 2 ) , A V a R (0.8 , mean_2 , s t d _ 2 ) , A V aR (0.9 , mean_2 , s t d _ 2 ) ]])

12 d a t a 1 = -1 * d a t a

13 fig = plt . f i g u r e ()

14 ax = fig . a d d _ a x e s ([0 ,0 ,1 ,1])

15 ax . bar ( X + 0.00 , d a t a 1 [0] , c o l o r = โ€™ b โ€™, w i d t h = 0 . 5 )

16 ax . bar ( X , d a t a [0] , c o l o r = โ€™ g โ€™, w i d t h = 0 . 5 )

17 c o l o r s = {โ€™ A V a R ( X ) โ€™:โ€™ b l u e โ€™,โ€™ - AV a R ( - X ) โ€™:โ€™ g r e e n โ€™}

18 l a b e l s = l i s t( c o l o r s . k e y s () )

19 h a n d l e s = [ plt . R e c t a n g l e ((0 ,0) ,1 ,1 , c o l o r = c o l o r s [ l a b e l ]) for l a b e l in l a b e l s ]

20 ax . l e g e n d ( handles , l a b e l s )

Listing A.3: AVaR and -AVaR

1 sns . s e t _ s t y l e (โ€™ d a r k g r i d โ€™)

2 sns . d i s t p l o t ( e r r o r _ 1 )

Listing A.4: Histogram

1 d a t a = np . a r r a y ([[ A V a R (0.1 , mean_2 , s t d _ 2 ) , A V a R (0.2 , mean_2 , s t d _ 2 ) ,

2 A V a R (0.3 , mean_2 , s t d _ 2 ) , A V a R (0.4 , mean_2 , s t d _ 2 ) , A V aR (0.5 , mean_2 , s t d _ 2 ) ,

3 A V a R (0.6 , mean_2 , s t d _ 2 ) ,

4 A V a R (0.7 , mean_2 , s t d _ 2 ) , A V a R (0.8 , mean_2 , s t d _ 2 ) , A V aR (0.9 , mean_2 , s t d _ 2 ) ]])

5 d a t a 1 = np . m u l t i p l y ( data , -1)

6 d a t a 2 =[[ V a r N o r m (0.775 ,0 ,1) * s t d _ 2 + mean_2 , V a r N o r m (0.8 ,0 ,1) * s t d _ 2 + mean_2 ,

7 V a r N o r m (0.825 ,0 ,1) * s t d _ 2 + mean_2 ,

8 V a r N o r m (0.85 ,0 ,1) * s t d _ 2 + mean_2 , V a r N o r m (0.875 ,0 ,1) * s t d _ 2 + mean_2 ,

9 V a r N o r m (0.9 ,0 ,1) * s t d _ 2 + mean_2 , V a r N o r m (0.925 ,0 ,1) * s t d _ 2 + mean_2 ,

(42)

10 V a r N o r m (0.95 ,0 ,1) * s t d _ 2 + mean_2 , V a r N o r m (0.975 ,0 ,1) * s t d _ 2 + m e a n _ 2 ]]

11 d a t a 3 = np . m u l t i p l y ( data2 , -1)

12 fig = plt . f i g u r e ()

13 ax = fig . a d d _ a x e s ([0 ,0 ,1 ,1])

14 ax . bar ( X + 0.05 , d a t a 2 [0] , c o l o r = โ€™ g โ€™, w i d t h = 0 . 0 4 )

15 ax . bar ( X , d a t a [0] , c o l o r = โ€™ b โ€™, w i d t h = 0 . 0 4 )

16 ax . bar ( X + 0.05 , d a t a 3 [0] , c o l o r = โ€™ g โ€™, w i d t h = 0 . 0 4 )

17 ax . bar ( X , d a t a 1 [0] , c o l o r = โ€™ b โ€™, w i d t h = 0 . 0 4 )

18 c o l o r s = {โ€™ A V a R ( X ) โ€™:โ€™ b l u e โ€™,โ€™ C on f lvl โ€™:โ€™ g r e e n โ€™}

19 l a b e l s = l i s t( c o l o r s . k e y s () )

20 h a n d l e s = [ plt . R e c t a n g l e ((0 ,0) ,1 ,1 , c o l o r = c o l o r s [ l a b e l ]) for l a b e l in l a b e l s ]

21 ax . l e g e n d ( handles , l a b e l s )

Listing A.5: AVaR and Conf lvl

1 def E R M _ h a n d ( teta , s i g m a ) :

2 e =1/ t e t a * np . log ( np . exp ( t e t a * t e t a * s i g m a * s i g m a /2) )

3 r e t u r n e

4 b = s t d _ n o r m a l

5 X = np . a r a n g e (0.1 ,1 ,0.1)

6 d a t a = [[ E R M _ h a n d (0.1 , b ) , E R M _ h a n d (0.2 , b ) , E R M _ h a n d (0.3 , b ) , E R M _ h a n d (0.4 , b ) , E R M _ h a n d (0.5 , b ) , E R M _ h a n d (0.6 , b ) , E R M _ h a n d (0.7 , b ) , E R M _ h a n d (0.8 , b ) , E R M _ h a n d (0.9 , b ) ]]

7 d a t a 2 = [[ A V a R (0.1 , m e a n _ n o r m a l , s t d _ n o r m a l ) , A V a R (0.2 , m e a n _ n o r m a l , s t d _ n o r m a l ) , A V a R (0.3 , m e a n _ n o r m a l , s t d _ n o r m a l ) ,

8 A V a R (0.4 , m e a n _ n o r m a l , s t d _ n o r m a l ) , A V a R (0.5 , m e a n _ n o r m a l , s t d _ n o r m a l ) , A V a R (0.6 , m e a n _ n o r m a l , s t d _ n o r m a l ) , A V a R (0.7 , m e a n _ n o r m a l , s t d _ n o r m a l ) ,

9 A V a R (0.8 , m e a n _ n o r m a l , s t d _ n o r m a l ) , A V a R (0.9 , m e a n _ n o r m a l , s t d _ n o r m a l ) ]]

10 plt . bar ( X , d at a [0] , c o l o r = โ€™ red โ€™, w i d t h = 0 . 0 5 )

11 plt . bar ( X + 0 . 0 5 , d a t a 2 [0] , c o l o r = โ€™ b l u e โ€™, w i d t h = 0 . 0 5 )

12 c o l o r s = {โ€™ E n t r o p i c r i s k m e a s u r e โ€™:โ€™ red โ€™,โ€™ A V a R โ€™:โ€™ b l u e โ€™}

13 l a b e l s = l i s t( c o l o r s . k e y s () )

14 h a n d l e s = [ plt . R e c t a n g l e ((0 ,0) ,1 ,1 , c o l o r = c o l o r s [ l a b e l ]) for l a b e l

(43)

in l a b e l s ]

15 plt . l e g e n d ( handles , l a b e l s )

16 plt . x l a b e l (โ€™ Teta - A l p h a โ€™)

17 plt . y l a b e l (โ€™ ERM - A Va R โ€™)

18 plt . t i t l e (โ€™ ERM wi t h S t a n d a r d N o r m a l d i s t and A V a R โ€™ )

Listing A.6: ERM with Standard Normal dist and AVaR

1 s = np . r a n d o m . n o r m a l ( mean_1 , std_1 , 2 4 3 )

2 fig = q q p l o t _ 2 s a m p l e s ( error_1 , s , l i n e =โ€™ 45 โ€™)

3 plt . s h o w ()

Listing A.7: QQ-plot

1 m e a n _ 1 0 0 = np . m e a n ( e r r o r _ 1 )

2 m e a n _ 1 0 = np . m e a n ( e r r o r _ 1 [ 2 2 5 : ] )

3 m e a n _ 2 0 = np . m e a n ( e r r o r _ 1 [ 2 0 0 : ] )

4 m e a n _ 3 0 = np . m e a n ( e r r o r _ 1 [ 1 7 5 : ] )

5 m e a n _ 4 0 = np . m e a n ( e r r o r _ 1 [ 1 5 0 : ] )

6 m e a n _ 5 0 = np . m e a n ( e r r o r _ 1 [ 1 2 5 : ] )

7 m e a n _ 6 0 = np . m e a n ( e r r o r _ 1 [ 1 0 0 : ] )

8 m e a n _ 7 0 = np . m e a n ( e r r o r _ 1 [ 7 5 : ] )

9 m e a n _ 8 0 = np . m e a n ( e r r o r _ 1 [ 5 0 : ] )

10 m e a n _ 9 0 = np . m e a n ( e r r o r _ 1 [ 2 5 : ] )

11 d a t a _ t a i l =[[ m e a n _ 1 0 0 , mean_90 , mean_80 , mean_70 , mean_60 , mean_50 , mean_40 , mean_30 , mean_20 , m e a n _ 1 0 ]]

12 plt . bar ( X , d a t a _ a v a r [0] , c o l o r = โ€™ red โ€™, w i d t h = 0 . 0 5 )

13 plt . bar ( X + 0 . 0 5 , d a t a _ t a i l [0] , c o l o r = โ€™ b l u e โ€™, w i d t h = 0 . 0 5 )

14 c o l o r s = {โ€™ A V a R โ€™:โ€™ red โ€™,โ€™ T a i l _ m e a n โ€™:โ€™ b l u e โ€™}

15 l a b e l s = l i s t( c o l o r s . k e y s () )

16 h a n d l e s = [ plt . R e c t a n g l e ((0 ,0) ,1 ,1 , c o l o r = c o l o r s [ l a b e l ]) for l a b e l in l a b e l s ]

17 plt . l e g e n d ( handles , l a b e l s )

18 plt . x l a b e l (โ€™ T a i l percent - A l p h a โ€™)

19 plt . y l a b e l (โ€™ AVaR - T a i l _ m e a n โ€™)

20 plt . t i t l e (โ€™ T a i l m e a n and A V a R โ€™ )

Listing A.8: Tail mean and AVaR

(44)

1 def V a r C h i 2 ( x , y ) :

2 s = s c i p y . s t a t s . c hi 2 . ppf ( x , df = y )

3 r e t u r n s

4 def A v a r C h i 2 ( t , y ) :

5 r e s u l t = (1/ (1 - t ) ) *f l o a t( i n t e g r a t e . q u a d (l a m b d a x : V a r C h i 2 ( x , y ) , t , 1) [ 0 ] )

6 r e t u r n r e s u l t

7 k = np . a r a n g e (0.1 , 1 , 0 . 1 )

8 y =[]

9 for j in r a n g e(9) :

10 for i in r a n g e(9) :

11 y . a p p e n d ( A v a r C h i 2 (( i +1) /10 , j +1) )

12 plt . p l o t ( k , y [:9] ,โ€™ g โ€™, l a b e l =โ€™ df =1 โ€™)

13 plt . p l o t ( k , y [9:18] ,โ€™ r โ€™, l a b e l =โ€™ df =2 โ€™)

14 plt . p l o t ( k , y [ 1 8 : 2 7] ,โ€™ b l u e โ€™, l a b e l =โ€™ df =3 โ€™)

15 plt . p l o t ( k , y [ 2 7 : 3 6] ,โ€™ y e l l o w โ€™, l a b e l =โ€™ df =4 โ€™)

16 plt . p l o t ( k , y [ 3 6 : 4 5] ,โ€™ v i o l e t โ€™, l a b e l =โ€™ df =5 โ€™)

17 plt . p l o t ( k , y [ 4 5 : 5 4] ,โ€™ b r o w n โ€™, l a b e l =โ€™ df =6 โ€™)

18 plt . p l o t ( k , y [ 5 4 : 6 3] ,โ€™ p u r p l e โ€™, l a b e l =โ€™ df =7 โ€™)

19 plt . p l o t ( k , y [ 6 3 : 7 2] ,โ€™ c h o c o l a t e โ€™, l a b e l =โ€™ df =8 โ€™)

20 plt . p l o t ( k , y [72:] ,โ€™ c o r a l โ€™, l a b e l =โ€™ df =9 โ€™)

21 plt . l e g e n d ()

22 plt . x l a b e l (โ€™ a l p h a โ€™, f o n t s i z e = 2 0 )

23 plt . y l a b e l (โ€™ A V a R at a l p h a โ€™, f o n t s i z e =2 0 )

24 plt . t i t l e (โ€™ C h i 2 โ€™, f o n t s i z e = 3 0 )

25 plt . s h o w ()

26 def V a r W e i ( x , y ) :

27 s = s c i p y . s t a t s . w e i b u l l _ m i n . ppf ( x , y )

28 r e t u r n s

29 def A v a r W e i ( t , y ) :

30 A V a R = (1/ (1 - t ) ) *f l o a t( i n t e g r a t e . q u a d (l a m b d a x : V a r W e i ( x , y ) , t , 1) [ 0 ] )

31 r e t u r n A V a R

32 plt . f i g u r e ()

33 k = np . a r a n g e (0.1 , 1. , 0 . 1 )

34 y =[]

(45)

35 for j in r a n g e(9) :

36 for i in r a n g e(9) :

37 y . a p p e n d ( A v a r W e i (( i +1) /10 , j +1) )

38 plt . p l o t ( k , y [:9] ,โ€™ g โ€™, l a b e l =โ€™ k =1 โ€™)

39 plt . p l o t ( k , y [9:18] ,โ€™ r โ€™, l a b e l =โ€™ k =2 โ€™)

40 plt . p l o t ( k , y [ 1 8 : 2 7] ,โ€™ b l u e โ€™, l a b e l =โ€™ k =3 โ€™)

41 plt . p l o t ( k , y [ 2 7 : 3 6] ,โ€™ y e l l o w โ€™, l a b e l =โ€™ k =4 โ€™)

42 plt . p l o t ( k , y [ 3 6 : 4 5] ,โ€™ v i o l e t โ€™, l a b e l =โ€™ k =5 โ€™)

43 plt . p l o t ( k , y [ 4 5 : 5 4] ,โ€™ b r o w n โ€™, l a b e l =โ€™ k =6 โ€™)

44 plt . p l o t ( k , y [ 5 4 : 6 3] ,โ€™ p u r p l e โ€™, l a b e l =โ€™ k =7 โ€™)

45 plt . p l o t ( k , y [ 6 3 : 7 2] ,โ€™ c h o c o l a t e โ€™, l a b e l =โ€™ k =8 โ€™)

46 plt . p l o t ( k , y [72:] ,โ€™ c o r a l โ€™, l a b e l =โ€™ k =9 โ€™)

47 plt . l e g e n d ()

48 plt . x l a b e l (โ€™ a l p h a โ€™, f o n t s i z e = 2 0 )

49 plt . y l a b e l (โ€™ A V a R at a l p h a โ€™, f o n t s i z e =2 0 )

50 plt . t i t l e (โ€™ W e i b u l l โ€™, f o n t s i z e = 3 0 )

51 plt . s h o w ()

52 def V a r S t u d e n t ( x , y , z ) :

53 s = s c i p y . s t a t s . nct . ppf ( x , y , z )

54 r e t u r n s

55 def A v a r S t u d e n t ( t , y ) :

56 A V a R = (1/ (1 - t ) ) *f l o a t( i n t e g r a t e . q u a d (l a m b d a x : V a r S t u d e n t ( x , y , 0 . 2 4 0 4 5 0 3 1 3 3 1 2 ) , t , 1) [ 0 ] )

57 r e t u r n A V a R

58 plt . f i g u r e ()

59 k = np . a r a n g e (0.1 , 1. , 0 . 1 )

60 y =[]

61 for j in r a n g e(9) :

62 for i in r a n g e(9) :

63 y . a p p e n d ( A v a r S t u d e n t (( i +1) /10 , j +1) )

64 plt . p l o t ( k , y [:9] ,โ€™ g โ€™, l a b e l =โ€™ k =1 โ€™)

65 plt . p l o t ( k , y [9:18] ,โ€™ r โ€™, l a b e l =โ€™ k =2 โ€™)

66 plt . p l o t ( k , y [ 1 8 : 2 7] ,โ€™ b l u e โ€™, l a b e l =โ€™ k =3 โ€™)

67 plt . p l o t ( k , y [ 2 7 : 3 6] ,โ€™ y e l l o w โ€™, l a b e l =โ€™ k =4 โ€™)

68 plt . p l o t ( k , y [ 3 6 : 4 5] ,โ€™ v i o l e t โ€™, l a b e l =โ€™ k =5 โ€™)

69 plt . p l o t ( k , y [ 4 5 : 5 4] ,โ€™ b r o w n โ€™, l a b e l =โ€™ k =6 โ€™)

(46)

70 plt . p l o t ( k , y [ 5 4 : 6 3] ,โ€™ p u r p l e โ€™, l a b e l =โ€™ k =7 โ€™)

71 plt . p l o t ( k , y [ 6 3 : 7 2] ,โ€™ c h o c o l a t e โ€™, l a b e l =โ€™ k =8 โ€™)

72 plt . p l o t ( k , y [72:] ,โ€™ c o r a l โ€™, l a b e l =โ€™ k =9 โ€™)

73 plt . l e g e n d ()

74 plt . x l a b e l (โ€™ a l p h a โ€™, f o n t s i z e = 2 0 )

75 plt . y l a b e l (โ€™ A V a R at a l p h a โ€™, f o n t s i z e =2 0 )

76 plt . t i t l e (โ€™ Student - T โ€™, f o n t s i z e = 3 0 )

77 plt . s h o w ()

78 def V a r E x p ( x , y ) :

79 s = s c i p y . s t a t s . e x p o n . ppf ( x , s c a l e =1/ y )

80 r e t u r n s

81 def A v a r E x p ( t , y ) :

82 A V a R = (1/ (1 - t ) ) *f l o a t( i n t e g r a t e . q u a d (l a m b d a x : V a r E x p ( x , y ) , t , 1) [ 0 ] )

83 r e t u r n A V a R

84 plt . f i g u r e ()

85 k = np . a r a n g e (0.1 , 1. , 0 . 1 )

86 y =[]

87 for j in r a n g e(9) :

88 for i in r a n g e(9) :

89 y . a p p e n d ( A v a r E x p (( i +1) /10 , j +1) )

90 plt . p l o t ( k , y [:9] ,โ€™ g โ€™, l a b e l =โ€™ l a m b d a =1 โ€™)

91 plt . p l o t ( k , y [9:18] ,โ€™ r โ€™, l a b e l =โ€™ l a m b d a =2 โ€™)

92 plt . p l o t ( k , y [ 1 8 : 2 7] ,โ€™ b l u e โ€™, l a b e l =โ€™ l a m b d a =3 โ€™)

93 plt . p l o t ( k , y [ 2 7 : 3 6] ,โ€™ y e l l o w โ€™, l a b e l =โ€™ l a m b d a =4 โ€™)

94 plt . p l o t ( k , y [ 3 6 : 4 5] ,โ€™ v i o l e t โ€™, l a b e l =โ€™ l a m b d a =5 โ€™)

95 plt . p l o t ( k , y [ 4 5 : 5 4] ,โ€™ b r o w n โ€™, l a b e l =โ€™ l a m b d a =6 โ€™)

96 plt . p l o t ( k , y [ 5 4 : 6 3] ,โ€™ p u r p l e โ€™, l a b e l =โ€™ l a m b d a =7 โ€™)

97 plt . p l o t ( k , y [ 6 3 : 7 2] ,โ€™ c h o c o l a t e โ€™, l a b e l =โ€™ l a m b d a =8 โ€™)

98 plt . p l o t ( k , y [72:] ,โ€™ c o r a l โ€™, l a b e l =โ€™ l a m b d a =9 โ€™)

99 plt . l e g e n d ()

100 plt . x l a b e l (โ€™ a l p h a โ€™, f o n t s i z e = 2 0 )

101 plt . y l a b e l (โ€™ A V a R at a l p h a โ€™, f o n t s i z e =2 0 )

102 plt . t i t l e (โ€™ E x p o n e n t i a l โ€™, f o n t s i z e = 3 0 )

103 plt . s h o w ()

104 def V a r N o r m ( x , y ) :

(47)

105 s = s c i p y . s t a t s . n or m . ppf ( x ,0 , y )

106 r e t u r n s

107 def A v a r N o r m ( t , y ) :

108 A V a R = (1/ (1 - t ) ) *f l o a t( i n t e g r a t e . q u a d (l a m b d a x : V a r N o r m ( x , y ) , t , 1) [ 0 ] )

109 r e t u r n A V a R

110 plt . f i g u r e ()

111 k = np . a r a n g e (0.1 , 1. , 0 . 1 )

112 y =[]

113 for j in r a n g e(9) :

114 for i in r a n g e(9) :

115 y . a p p e n d ( A v a r N o r m (( i +1) /10 , j +1) )

116 plt . p l o t ( k , y [:9] ,โ€™ g โ€™, l a b e l =โ€™ std =1 โ€™)

117 plt . p l o t ( k , y [9:18] ,โ€™ r โ€™, l a b e l =โ€™ std =2 โ€™)

118 plt . p l o t ( k , y [ 1 8 : 2 7] ,โ€™ b l u e โ€™, l a b e l =โ€™ std =3 โ€™)

119 plt . p l o t ( k , y [ 2 7 : 3 6] ,โ€™ y e l l o w โ€™, l a b e l =โ€™ std =4 โ€™)

120 plt . p l o t ( k , y [ 3 6 : 4 5] ,โ€™ v i o l e t โ€™, l a b e l =โ€™ std =5 โ€™)

121 plt . p l o t ( k , y [ 4 5 : 5 4] ,โ€™ b r o w n โ€™, l a b e l =โ€™ std =6 โ€™)

122 plt . p l o t ( k , y [ 5 4 : 6 3] ,โ€™ p u r p l e โ€™, l a b e l =โ€™ std =7 โ€™)

123 plt . p l o t ( k , y [ 6 3 : 7 2] ,โ€™ c h o c o l a t e โ€™, l a b e l =โ€™ std =8 โ€™)

124 plt . p l o t ( k , y [72:] ,โ€™ c o r a l โ€™, l a b e l =โ€™ std =9 โ€™)

125 plt . l e g e n d ()

126 plt . x l a b e l (โ€™ a l p h a โ€™, f o n t s i z e = 2 0 )

127 plt . y l a b e l (โ€™ A V a R at a l p h a โ€™, f o n t s i z e =2 0 )

128 plt . t i t l e (โ€™ G a u s i a n โ€™, f o n t s i z e = 3 0 )

129 plt . s h o w ()

Listing A.9: AVaRs of different distributions

1 b = s t d _ n o r m a l

2 X = np . a r a n g e (0.1 ,1 ,0.1)

3 d a t a = [[ E R M _ h a n d (0.1 , b ) , E R M _ h a n d (0.2 , b ) , E R M _ h a n d (0.3 , b ) , E R M _ h a n d (0.4 , b ) , E R M _ h a n d (0.5 , b ) , E R M _ h a n d (0.6 , b ) , E R M _ h a n d (0.7 , b ) , E R M _ h a n d (0.8 , b ) , E R M _ h a n d (0.9 , b ) ]]

4 d a t a 2 = [[ A V a R (0.1 , m e a n _ n o r m a l , s t d _ n o r m a l ) , A V a R (0.2 , m e a n _ n o r m a l , s t d _ n o r m a l ) , A V a R (0.3 , m e a n _ n o r m a l , s t d _ n o r m a l ) ,

5 A V a R (0.4 , m e a n _ n o r m a l , s t d _ n o r m a l ) , A V a R (0.5 , m e a n _ n o r m a l ,

(48)

s t d _ n o r m a l ) , A V a R (0.6 , m e a n _ n o r m a l , s t d _ n o r m a l ) , A V a R (0.7 , m e a n _ n o r m a l , s t d _ n o r m a l ) ,

6 A V a R (0.8 , m e a n _ n o r m a l , s t d _ n o r m a l ) , A V a R (0.9 , m e a n _ n o r m a l , s t d _ n o r m a l ) ]]

7 d a t a 3 = [[ - E R M _ h a n d (0.1 , b ) , - E R M _ h a n d (0.2 , b ) , - E R M _ h a n d (0.3 , b ) , -

E R M _ h a n d (0.4 , b ) , - E R M _ h a n d (0.5 , b ) , - E R M _ h a n d (0.6 , b ) , - E R M _ h a n d (0.7 , b ) , - E R M _ h a n d (0.8 , b ) , - E R M _ h a n d (0.9 , b ) ]]

8 d a t a 4 = [[ - A V a R (0.1 , m e a n _ n o r m a l , s t d _ n o r m a l ) , - A V a R (0.2 , m e a n _ n o r m a l , s t d _ n o r m a l ) , - A V a R (0.3 , m e a n _ n o r m a l , s t d _ n o r m a l ) ,

9 - A V a R (0.4 , m e a n _ n o r m a l , s t d _ n o r m a l ) , - A V a R (0.5 , m e a n _ n o r m a l , s t d _ n o r m a l ) , - A V a R (0.6 , m e a n _ n o r m a l , s t d _ n o r m a l ) , - A V a R (0.7 , m e a n _ n o r m a l , s t d _ n o r m a l ) ,

10 - A V a R (0.8 , m e a n _ n o r m a l , s t d _ n o r m a l ) , - A V a R (0.9 , m e a n _ n o r m a l , s t d _ n o r m a l ) ]]

11

12 plt . bar ( X , d at a [0] , c o l o r = โ€™ red โ€™, w i d t h = 0 . 0 5 )

13 plt . bar ( X + 0 . 0 5 , d a t a 2 [0] , c o l o r = โ€™ b l u e โ€™, w i d t h = 0 . 0 5 )

14 plt . bar ( X , d a t a 3 [0] , c o l o r = โ€™ red โ€™, w i d t h = 0 . 0 5 )

15 plt . bar ( X + 0 . 0 5 , d a t a 4 [0] , c o l o r = โ€™ b l u e โ€™

ะกัƒั€ะตั‚

Figure 1-1: Standard Normal Distribution
Figure 1-2: Chi square distribution with different df
Figure 1-3: Exponential distribution with different ๐œ†
Figure 1-4: Student-t distribution with different degree of freedom
+7

ะา›ะฟะฐั€ะฐั‚ ะบำฉะทะดะตั€ั–

ะกำ˜ะ™ะšะ•ะก ะšะ•ะ›ะ•ะขะ†ะ าšาฐะ–ะะขะขะะ