diff options
-rw-r--r-- | Year_3/MMS/corr_data.m | 7 | ||||
-rw-r--r-- | Year_3/MMS/crime.mat | bin | 0 -> 482 bytes | |||
-rw-r--r-- | Year_3/MMS/earth.mat | bin | 0 -> 318 bytes | |||
-rw-r--r-- | Year_3/MMS/fish.mat | bin | 0 -> 6471 bytes | |||
-rw-r--r-- | Year_3/MMS/iris.mat | bin | 0 -> 5136 bytes | |||
-rw-r--r-- | Year_3/MMS/lecture_20211123.m | 39 | ||||
-rw-r--r-- | Year_3/MMS/nations.mat | bin | 0 -> 514 bytes | |||
-rw-r--r-- | Year_3/MMS/normal_distribution.m | 14 |
8 files changed, 60 insertions, 0 deletions
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 Binary files differnew file mode 100644 index 0000000..9937b5d --- /dev/null +++ b/Year_3/MMS/crime.mat diff --git a/Year_3/MMS/earth.mat b/Year_3/MMS/earth.mat Binary files differnew file mode 100644 index 0000000..10f315d --- /dev/null +++ b/Year_3/MMS/earth.mat diff --git a/Year_3/MMS/fish.mat b/Year_3/MMS/fish.mat Binary files differnew file mode 100644 index 0000000..92d5696 --- /dev/null +++ b/Year_3/MMS/fish.mat diff --git a/Year_3/MMS/iris.mat b/Year_3/MMS/iris.mat Binary files differnew file mode 100644 index 0000000..97cdc98 --- /dev/null +++ b/Year_3/MMS/iris.mat 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 Binary files differnew file mode 100644 index 0000000..1d164fe --- /dev/null +++ b/Year_3/MMS/nations.mat 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 |