%Nahodna velicina D
echo off; cla; clear;

a = 58;
b = 80;
c = 3/44;
i1 = 196/3;
i2 = 218/3;
deleni = 0.01;

%PDF na intervalu <a;i1>:
xD1 = a:deleni:i1;
yD1 = repmat(c/2,1,length(xD1));
%PDF na intervalu <i1;i2>:
xD2 = i1:deleni:i2;
yD2 = repmat(c,1,length(xD2));
%PDF na intervalu <i2;b>:
xD3 = i2:deleni:b;
yD3 = repmat(c/2,1,length(xD3));



c1 = -87/44;
c2 = -185/44;
c3 = -19/11;

%PDF na intervalu <a;i1>:
yD1_cdf = c/2 * xD1 + c1;
%PDF na intervalu <i1;i2>:
yD2_cdf = c * xD2 + c2;
%PDF na intervalu <i2;b>:
yD3_cdf = c/2 * xD3 + c3;

xD = [xD1,xD2,xD3];
yD_cdf = [yD1_cdf,yD2_cdf,yD3_cdf];


hold on;
plot(xD1,yD1,'r');
plot(xD2,yD2,'r');
plot(xD3,yD3,'r');
plot(xD,yD_cdf,'b');
hold off;