%
% Today is about statistics (descriptive)

clear all; clc; close all;
x=[9 10 10 9 9 8 7 3 10 9 8 5 10]
mean4=mymean4(x)
mean4test=mean(x)

x1=[8 7 5 4 6];
meanx1=mean(x1);
varx1=((8-meanx1)^2+ (7-meanx1)^2+ (5-meanx1)^2+ (4-meanx1)^2 +(6-meanx1)^2)/4;
varx1b=var(x1)
varx1u=myvar5(x1)
stdx1=std(x1)
stdx1s=sqrt(var(x1))

% Histogram example
% Start by generating some random data

x2 = randn(1,10000);
figure(1)
hist(x2) 
% Or we can specify the bins and range
figure(2)
[N,X] = hist(x2,[-5:1:5]);
bar(X,N)

%

function [myaverage] = mymean4(vec)
% This function will calculate the mean of a vector
mysum4=0;
for i=1:1:length(vec)
    mysum4=mysum4+vec(i);
end
myaverage=mysum4/length(vec)
end
function [myvar] = myvar5(vec)
% This function will calculate the mean of a vector
mysum5=0;
m=mean(vec); % average or mean of the vector
for i=1:length(vec)
    mysum5=mysum5+(vec(i)-m)^2;
end
myvar=mysum5/(length(vec)-1)
end