-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNormalDistribution.m
More file actions
68 lines (65 loc) · 1.66 KB
/
NormalDistribution.m
File metadata and controls
68 lines (65 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
%Question 2
%Normal distribution
clc;
clear all
digits (4)
% miu = 3;
% sigma = 1/3;
% sect = 3;
% sect2 = 2.5;
%
% syms P(x)
% P(x) = exp(-(x-miu).^2/(2*sigma^2))/(sigma*sqrt (2*pi));
%
% alpha = double (vpaintegral (P, x, [sect2, sect]));
%
% beta= double (vpa (P(miu)));
% delta1 = double (vpa (P(sect)));
% delta2 = double (vpa (P(sect2)));
% deltas1 = double (vpa (P(miu-sigma)));
% deltas2 = double (vpa (P(miu+sigma)));
% deltas3 = double (vpa (P(miu+2*sigma)));
% deltas4 = double (vpa (P(miu-2*sigma)));
%
% hold on
% %xlim auto
% %ylim auto
%
% fplot (P, 'm');
% line ([miu, miu], [0, beta], 'Color', 'cyan');
% line ([-1.5+miu, 1.5+miu],[0, 0]);
% line ([sect, sect], [0, delta1], 'Color', 'black');
% line ([sect2, sect2], [0, delta2], 'Color', 'black');
% line ([miu - sigma, miu - sigma], [0, deltas1], 'Color', 'blue');
% line ([miu + sigma, miu + sigma], [0, deltas2], 'Color', 'blue');
% line ([miu - 2*sigma, miu - 2*sigma], [0, deltas3], 'Color', 'blue');
% line ([miu + 2*sigma, miu + 2*sigma], [0, deltas4], 'Color', 'blue');
% xlabel ('years');
% hold off
%
% %Answer i:
% z1m = (sect2 - miu) / sigma;
% Answeri = double (alpha) + 0.5;
%
% %Answer ii:
% Answerii = double (vpaintegral (P, x, [2, 3]));
%
% %Answer iii:
% Answeriii = 100 - double (P(3));
%
% %Answer b)
% Answerb = 0.67 * sigma + miu;
%
% %Answer c)
% Answerc = 1.64 * sigma + miu;
%Question 3
%Linear Regression
w = [1975, 1215, 1008, 1323, 710, 1350, 1436, 1561, 2120, 2100];
c = [12.7, 30.1, 33.0, 21.3, 41.6, 25.0, 21.1, 22.6, 13.3, 13.6];
w= w + 9;
digits (4); %sets dp to 4
p = polyfit (w,c,1);
x = linspace (500,2500,200);
y = polyval (p, x);
plot(x,y,w,c,'o')
title(num2str(clock))