Graphical representation of Value at Risk

1 回表示 (過去 30 日間)
Alessio Imperi Galli
Alessio Imperi Galli 2022 年 3 月 13 日
回答済み: Prahlad Gowtham Katte 2022 年 3 月 17 日
Hello, everyone,
I would like to graphically represent Value at Risk by colouring the area under the graph of a density function associated with the alpha confidence level. In other words I would like to replicate a figure like the one attached.
Thank you all and have a nice day :)
  2 件のコメント
Torsten
Torsten 2022 年 3 月 13 日
編集済み: Torsten 2022 年 3 月 13 日
The area to the left looks greater than 0.05 :-)
Alessio Imperi Galli
Alessio Imperi Galli 2022 年 3 月 13 日
I think it was just a demonstrative image

サインインしてコメントする。

回答 (1 件)

Prahlad Gowtham Katte
Prahlad Gowtham Katte 2022 年 3 月 17 日
Hello
As per my understanding of the query you want to indicate certain areas within the curve with a different color and this can be achieved by area function. The code below is an example of how you can change the colors within the area under curve.
mu = 0.5;
sigma = 1;
pd = makedist('Normal','mu',mu,'sigma',sigma);
x = -4:0.1:6;
y = pdf(pd,x);
x_color=x(1:length(x(x<=0.05)));% x co-ordinates of required area
y_color=y(1:length(x(x<=0.05)));% y co-ordinates of required area
area(x_color,y_color,'FaceColor','r');% coloring the required area with red
x_color=x(length(x(x<=0.05)):end);
y_color=y(length(x(x<=0.05)):end);
hold on;
area(x_color,y_color,'FaceColor','g');%coloring the rest of the area with green
For more information on how to use area function please refer to the following link
Hope it helps!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by