From a44b9ed57ffebfa5b13b29e94c7da97bed99911b Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Mon, 29 Nov 2021 22:30:01 +0100 Subject: mms: add lecture --- Year_3/MMS/corr_data.m | 7 +++++++ Year_3/MMS/crime.mat | Bin 0 -> 482 bytes Year_3/MMS/earth.mat | Bin 0 -> 318 bytes Year_3/MMS/fish.mat | Bin 0 -> 6471 bytes Year_3/MMS/iris.mat | Bin 0 -> 5136 bytes Year_3/MMS/lecture_20211123.m | 39 +++++++++++++++++++++++++++++++++++++++ Year_3/MMS/nations.mat | Bin 0 -> 514 bytes Year_3/MMS/normal_distribution.m | 14 ++++++++++++++ 8 files changed, 60 insertions(+) create mode 100644 Year_3/MMS/corr_data.m create mode 100644 Year_3/MMS/crime.mat create mode 100644 Year_3/MMS/earth.mat create mode 100644 Year_3/MMS/fish.mat create mode 100644 Year_3/MMS/iris.mat create mode 100644 Year_3/MMS/lecture_20211123.m create mode 100644 Year_3/MMS/nations.mat create mode 100644 Year_3/MMS/normal_distribution.m diff --git a/Year_3/MMS/corr_data.m b/Year_3/MMS/corr_data.m new file mode 100644 index 0000000..0309e05 --- /dev/null +++ b/Year_3/MMS/corr_data.m @@ -0,0 +1,7 @@ +function f = corr_data(data1, data2) + f = corrcoef(data1, data2); + disp("Matrix " + f) + plot(data1, data2, "x") + xlabel("Data1") + ylabel("Data2") +end \ No newline at end of file diff --git a/Year_3/MMS/crime.mat b/Year_3/MMS/crime.mat new file mode 100644 index 0000000..9937b5d Binary files /dev/null and b/Year_3/MMS/crime.mat differ diff --git a/Year_3/MMS/earth.mat b/Year_3/MMS/earth.mat new file mode 100644 index 0000000..10f315d Binary files /dev/null and b/Year_3/MMS/earth.mat differ diff --git a/Year_3/MMS/fish.mat b/Year_3/MMS/fish.mat new file mode 100644 index 0000000..92d5696 Binary files /dev/null and b/Year_3/MMS/fish.mat differ diff --git a/Year_3/MMS/iris.mat b/Year_3/MMS/iris.mat new file mode 100644 index 0000000..97cdc98 Binary files /dev/null and b/Year_3/MMS/iris.mat differ diff --git a/Year_3/MMS/lecture_20211123.m b/Year_3/MMS/lecture_20211123.m new file mode 100644 index 0000000..0038f72 --- /dev/null +++ b/Year_3/MMS/lecture_20211123.m @@ -0,0 +1,39 @@ +fish = readtable("fish.txt"); +p = table2array(fish(:, 2)); % Import the Price 1970 col from "fish.txt" + +mean(p); +median(p); +min(p); +max(p); +range(p); + +xvar = var(p); +xdev = std(p); +sqrt(xvar) == xdev; % Prints "1" + +% --- +load("nations.mat"); +MC = cov(nations); +size(MC); +data1 = nations(:, 1); +data2 = nations(:, 2); + +corrcoef(data1, data2); + +% plot(data1, data2, 'x'); + +load("T.mat"); +Tarray = table2array(T); +sp = Tarray(:, 1); +dn = Tarray(:, 2); +corr = corrcoef(sp, dn); + +disp(corr); +plot(sp, dn, 'x') +xlabel("Speed"); +ylabel("Density"); + +load earth; +histogram(earth); +histfit(earth); +quantile(earth, 2); diff --git a/Year_3/MMS/nations.mat b/Year_3/MMS/nations.mat new file mode 100644 index 0000000..1d164fe Binary files /dev/null and b/Year_3/MMS/nations.mat differ diff --git a/Year_3/MMS/normal_distribution.m b/Year_3/MMS/normal_distribution.m new file mode 100644 index 0000000..5250a84 --- /dev/null +++ b/Year_3/MMS/normal_distribution.m @@ -0,0 +1,14 @@ +function fn = normal_distribution(data) + mu = mean(data); + sig = var(data); + + f = @(x) (1/sig/sqrt(2*pi))*exp(-0.5*(x-mu).^2/sig^2); + xmin = min(data); + xmax = max(data); + + deltax = abs(xmax-xmin)/50; + x = xmin:deltax:xmax; + y = f(x); + + plot(x, y); +end \ No newline at end of file -- cgit v1.2.3-18-g5258