0% found this document useful (0 votes)
9K views37 pages

Mat523 Mini Project PDF

The document summarizes a mini project assignment on analyzing the number of reported rape cases in Malaysia from 2000 to 2017 using linear, quadratic, and cubic models. It finds the best fit equations for each model by using the least squares method and calculates the error vectors. Based on the error magnitudes, it determines that the cubic model provides the best fit with the smallest error magnitude.

Uploaded by

Izyan Nabilah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9K views37 pages

Mat523 Mini Project PDF

The document summarizes a mini project assignment on analyzing the number of reported rape cases in Malaysia from 2000 to 2017 using linear, quadratic, and cubic models. It finds the best fit equations for each model by using the least squares method and calculates the error vectors. Based on the error magnitudes, it determines that the cubic model provides the best fit with the smallest error magnitude.

Uploaded by

Izyan Nabilah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

MAT523

LINEAR ALGEBRA 2

MINI PROJECT ASSIGNMENT:


THE NUMBER OF RAPE CASES (2000-2017)

PRERARED BY:

NAME MATRIC NO
AUNI ARDINI BINTI ADDY AZHAR 2020819486

HANIS THURAIYA BINTI AHMAD 2020449838


NASIM

NOR LAILI SOBRINA BINTI ISHAK 2020878112


SHAIRAZI

GROUP:
T5CS2672B2

PREPARED FOR:
DR.NUR ATIKAH SALAHUDIN

DATE OF SUBMISSION:
6 MAY 2021
INDEX

NO CONTENT PAGE
1 Introduction 2

2 Medhotology

2.1 Linear Model 3

2.2 Quadratic Model 7

2.3 Cubic Model 11

3 Conclusion 15

4 Appendix 16

1
1.INTRODUCTION

The table below is the data about the investigation on the number of rape cases. The
data or statistic are based on cases reported to the Royal Malaysia Police (PDRM)
and collected from 2000 until 2017. We can define that the year as variable X and the
number of rape cases as variable Y,since the number of cases was increasing by year.
We have to observe by using 3 model which are Linear Model, Quadraric Model and
Cubic Model and calculating the best fit curve for the data.

Table 1: The Data of Number of Rape Cases per year in Malaysia


Year,X 1 2 3 4 5 6 7 8 9
Number 1217 1386 1431 1479 1760 1931 2454 3098 3409
of rape
cases,Y

Year,X 10 11 12 13 14 15 16 17 18
Number 3626 3595 3301 2998 2767 2045 1873 1698 1582
of rape
cases,Y

*data cases from 2000-2017

2
2. METHODOLOGY

2.1 Linear Model, y=a+bx

a) Find the equation of the curve by using the least squares method.

(MTM)v=MTv v=(MTM)-1((MTy)

(MTM)=

(MTM)-1=

3
MTy=

Therefore: v = (MTM)-1((MTy)

v=

The best fit line: a+bx=y

y=

4
b)Find the error vector and the magnitude of this error vector.

e= - =

Magnitude of error :

||e||= 3322.180495

5
b) Plot the graphs:
I. Points of scattered data and best fir curve that you have calculated.

ii) Graphs of residuals (error vector) around the x-axis(y=0)

6
2.2 Quadratic Model, y= a + bx + cx²
a) Find the equation of the curve by using the least squares method

(MTM)v = MTv v = (MTM)-1((MTy)

(MTM) =

(MTM)-1
=

7
(MTy) =

v=

The best fit line :y= a+bx+cx2

y=

8
b) Find the error vector and the magnitude of this error vector.

e=y-Mv

e= - =

Magnitude vector error, ||e||=

9
c) Plot the graphs
i) Points of scattered data and best fit curve that you have calculated.

ii) Graph of residuals (error vector) around the x-axis (y=0)

10
2.3 Cubic model y = a + bx + cx² + dx³

a) Find the equation of the curve by using the least squares method.

(MTM)v = MTv v = (MTM)-1((MTy)

(MTM) =

(MTM)-1=

11
(MTy) =

v=

The best fit line : y = a + bx + cx² + dx³

y=

12
b) Find the error vector and the magnitude of this error vector.
Error vector, e = y -Mv

e= - =

Magnitude of vector error, ||e|| = 1377.138958

13
c) Plot the graphs:
i. Points od scattered data and best fit curve that you have calculated.

ii. Graphs of residuals (error vector) around the x-axis (y=0)

14
3. CONCLUSION
Based on the investigation that we have done, there are many ways toknowthe best
method that can be used based on the method :

Type of best fit curve Error Magnitude (unit)


Linear Equation 3322.180495
Linear Quadratic Equation 3.310892562 x 109
Linear Cubic Equation 1377.138958

Therefore from the research that we have done, the best method that can be use for
this problem is linear cubic equation method because linear cubic equation has the
smallest magnitude of error than linear equation and linear quadratic equation.

*error magnitude graph of the best method

15
4. APPENDIX

o Maple command for Linear Model


COMMAND OUTPUT
Interface (rtablesize=50)

A:= Matrix(18,1,fill=1)

B:=<1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
16,17,18>

x:=<1217,1386,1431,1479,1760,1930,
2455,3098,3409,3629,3595,3301,2998,
2767,2045,1873,1698,1552> A:= B:= x:=

16
M:=<A|B>

M:=

M+

c:=M+M
c:=

d:=LinearAlgebra[MatrixInverse](c)
d:=

f:=
f:=M+x

v:=
v:=d.f

17
g:=M.v

e:=x-g

g:= e:=

evalf(VectorCalculus[Norm](e))
|e|:=

18
restart
with(plots)

A:=[[1, 1217], [2, 1386], [3, 1431], [4,


1479], [5, 1760], [6, 1931], [7, 2455], [8,
3098], [9, 3409], [10, 3629], [11, 3595], [12,
3301], [13, 2998], [14, 2767], [15, 2045],
[16, 1873], [17, 1698], [18, 1552]]

B:= 286555/153+(44827/969)*x

plot([A, B], x = 0 .. 18, y = 1200 .. 3000, color


= ["Red", "Blue"])

19
restart
with(stats[fit])

A := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,


13, 14, 15, 16, 17, 18]

B := [1217, 1386, 1431, 1479, 1760,


1930, 2455, 3098, 3409, 3629, 3595,
3301, 2998, 2767, 2045, 1873, 1698,
1552]

m := 286555/153+(44827/969)*x

x := 44827/969

y := 286555/153

resid := seq([1217, 1386, 1431, 1479,


1760, 1930, 2455, 3098, 3409, 3629,
3595, 3301, 2998, 2767, 2045, 1873,
1698, 1552][i]-x . [1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17, 18][i]-
y, i = 1 .. 18)

20
plot([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18], [resid], symbol =
solidcircle)

21
o Maple command for Quadratic Model
interface(rtablesize = 50)

A := Matrix(18, 1, fill = 1)

22
x := <1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18>

X := <12, 22, 32, 42, 52, 62, 72, 82, 92, 102,
112, 122, 132, 142, 152, 162, 172, 182>

y := <1217, 1386, 1431, 1479, 1760, 1930,


2455, 3098, 3409, 3629, 3595, 3301, 2998,
2767, 2045, 1873, 1698, 1552>

M := <<A>|<x>|<X>>

23
m := M+M

inverse := LinearAlgebra[MatrixInverse](m)

f :=M+y

v := inverse . f

mv := M . f

24
e := y-mv

evalf(VectorCalculus[Norm](e)) |e|=

25
restart
with(plots);
A := [[1, 1217], [2, 1386], [3, 1431], [4, 1479], [5,
1760], [6, 1931], [7, 2455], [8, 3098], [9, 3409], [10,
3629], [11, 3595], [12, 3301], [13, 2998], [14, 2767],
[15, 2045], [16, 1873], [17, 1698], [18, 1552]]

B := -(26099/912)*x^2+(9147209/15504)*x+8225/136

plot([A, B], x = 1 .. 18, y = 0 .. 3000, color = ["Red",


"Blue"])

26
restart
with(stats[fit]);

year := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, year:=
17, 18]

cases:=[1217, 1386, 1431, 1479, 1760, 1930, 2455, 3098, cases:=


3409, 3629, 3595, 3301, 2998, 2767, 2045, 1873, 1698,
1552]

eqn := -(26099/912)*x^2+(9147209/15504)*x+8225/136 eqn:=

a := -26099/912 a:=

b := 9147209/15504 b:=

c := 8225/136 c:=

E := [5466351, 20904871, 46357183, 81823287, E:=


127303183, 182796871, 248304351, 323825623,
409360687, 504909543, 610472191, 726048631,
851638863, 987242887, 1132860703, 1288492311,
1454137711, 1629796903]

with(plots); resid := seq(y[i]-E[i], i = 1 .. 18)

27
plot([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18], [resid], symbol = solidcircle)

28
o Maple Command for Cubic Model
COMMAND OUTPUT
interface(rtablesize = 50)

A := Matrix(18, 1, fill = 1)
A:=

29
aa := <1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18>

aaa := <12, 22, 32, 42, 52, 62, 72, 82,


92, 102, 112, 122, 132, 142, 152, 162,
172, 182>
aa:= aaa:= aaaa:=
aaaa := <13, 23, 33, 43, 53, 63, 73, 83,
93, 103, 113, 123, 133, 143, 153, 163,
173, 183>

M:=<<A>|<aa>\<aaa.>\<aaaa>>

M:=

30
y:= `<,>`(1217, 1386, 1431, 1479,
1760, 1930, 2455, 3098, 3409, 3629,
3595, 3301, 2998, 2767, 2045, 1873,
1698, 1552)
y:=

M+

c:=M+M c:=

d:=LinearAlgebra[MatrixInverse](c) d:=

31
f:=M+y
f:=

v := d . f v:=

g := M . v
g:=

32
e := y-g
e:=

evalf(VectorCalculus[Norm](e)) |e|=

33
restart
with(plots)
A := [[1, 1217], [2, 1386], [3, 1431], [4, 1479], [5, A:=
1760], [6, 1930], [7, 2455], [8, 3098], [9, 3409],
[10, 3629], [11, 3595], [12, 3301], [13, 2998], [14,
2767], [15, 2045], [16, 1873], [17, 1698], [18,
1552]]

eqn:= eqn:=
158585/204+(4423651/23256)*x+(14593/646)*x2-
(41785/23256)*x3

plot([A, e], x = 0 .. 18, y = 0 .. 4000, color = ["Red",


"Blue"])

34
restart
with(stats[fit]);

year := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, year:=


14, 15, 16, 17, 18]

cases := [1217, 1386, 1431, 1479, 1760, 1930, cases:=


2455, 3098, 3409, 3629, 3595, 3301, 2998,
2767, 2045, 1873, 1698, 1552]

eqn:= eqn:=
158585/204+(4423651/23256)*x+(14593/646)
*x2-(41785/23256)*x3

a := 158585/204 a:=

b := 4423651/23256 b:=

c := 14593/646 c:=

d := -41785/23256 d:=

E := [56338/57, 1195546/969, 2912465/1938, E:=


6917437/3876, 668160/323, 1514099/646,
1679279/646, 10949375/3876, 2915978/969,
3044375/969, 6224177/1938, 12434689/3876,
3023680/969, 99883/34, 1711455/646,
2899713/1292, 1659026/969, 59380/57]

35
with(plots); resid := seq(cases[i]-E[i], i = 1 ..
18)

plot([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,


15, 16, 17, 18], [resid], symbol = solidcircle)

36

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy