%% A modern Introduction to Probability and Statistics
% Matlab excercises
%
% Author: Djordje Gligorijevic
% email: gligorijevic@temple.edu

%% Excercise 1: Draw histograms for the following dataset:
Dataset1 = [12, 15, 34, 24, 35, 67, 89, 13, 45, 36, 89, 46, 97, 34, 56, 78, 65, 83, 59, 74];

% 3.1) Let the bin width be 10, the first bin starts at 10;
% 3.2)  Let the bin width be 30, the first bin starts at 10;
% 3.3) Let the bin width be 50, the first bin starts at 10;

%% Excercise 2:
% Given the following dataset, which contains the prime numbers less than 100.
Dataset2 = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97];

% 4.1) Compute the sample median.
% 4.2) Compute the lower and upper quartiles.

%% Excercise 3:
% Given the following dataset, which contains Fibonacci numbers less than 100.
Dataset3 = [0,1,1,2,3,5,8,13,21,34,55,89];

% 5.1) Compute the standard deviation.
% 5.2) Compute the MAD(mean absolute deviation).

%% Excercise 4:
% Plot in a 3-D figure of the joint distribution of following table 
% (which is based on the magical square in Albrecht Durer’s engraving 
% Melencolia I)
x = [1:4]; 
y = [1:4]; 
joint = [16/136 3/136 2/136 13/136;
    5/136 10/136 11/136 8/136;
    9/136 6/136 7/136 12/136;
    4/136 15/136 14/136 1/136];


%% Excercise 6
% Plot a 3-D figure of the joint distribution with following function
x = 2:6;
y = 0:25;
joint_function = @(x, y) (2*x + y)/210;

