%% SL 13
% script evaluates two hyperbolic 
%  functions and plot them
x  = linspace(-1, 1, 51);
f1 = sinh(x);
f2 = cosh(x);
plot(x, f1, 'bs-');
hold on;
plot(x, f2, 'rd--');
ylim([-1.5 1.5]);
legend('f_1(x)=sinh(x)', 'f_2(x)=cosh(x) ', ...
'Location', 'best');
xlabel('x'); 
ylabel('f_1(x), f_2(x)');
grid on;

%% SL 17
close all; clear; clc;
x1 = -1:0.2:1;
x2 = -1:0.1:1;
x3 = -1:0.01:1;
f1 = x1.*sin(pi/2*(1+20*x1));
f2 = x2.*sin(pi/2*(1+20*x2));
f3 = x3.*sin(pi/2*(1+20*x3));
figure;
hold on; grid on;
plot(x1, f1, 'r');
plot(x2, f2, 'g');
plot(x3, f3, 'b');
legend('0.2', '0.1', '0.01');

%% SL 28
L = 1e5;
tosses = randi(8, 1, L);
histogram(tosses);

%% SL30
clc, clear
N = 1e4; % number of series
M = 1e3; % number of throws in one set
throws = randi([0 1], M, N)*2-1; % generate numbers -1 and 1
nOnes = sum(throws == 1);
nOnesOverAverage = sum(throws); % is vector
figure(1);
histogram(nOnesOverAverage, 60); % 60 bins

mean(nOnesOverAverage)
std(nOnesOverAverage)

%% SL 31
figure(2);
histogram(0 + 31.62*randn(N,1), 60);



