SlideShare a Scribd company logo
Programming
Meeting #8
EEC: T.Hideyuki
Programming
Meeting #8
Least Squares
Practice
What's next?
+
Programming
Meeting #8
Least Squares
x
y
O
1
2
3
4
1 2 3 4 65 7
Error
Programming
Meeting #8
Least Squares
x
y
1
2
3
4
1 2 3 4 65 7
y- intercept
Slope
Programming
Meeting #8
Least
Squares
Data
Slope
y-intercept
Least Squares
Programming
Meeting #8
Data
Least Squares
Programming
Meeting #8
DataLeast Squares
Coordinates
(X,Y)
Programming
Meeting #8
DataLeast Squares
Variable Array
Coordinates
(X,Y)
Programming
Meeting #8
DataLeast Squares
Array
x = [1.0, 2.0, 3.0, 4.0, 5.0]
y = [1.3, 1.8, 2.8, 2.5, 3.9]
Programming
Meeting #8
x
y
O
1
2
3
4
1 2 3 4 65 7
x = [1.0, 2.0, 3.0, 4.0, 5.0]
y = [1.3, 1.8, 2.8, 2.5, 3.9]
Least Squares
0
2 3
4
Data
1
Programming
Meeting #8
n xy x y
n x x2
2
α
( )
=
Σ −Σ Σ
Σ − Σ
The slope
The number of points
Arrays
Least Squares
Programming
Meeting #8
n xy x y
n x x2
2
α
( )
=
Σ −Σ Σ
Σ − Σ
The slopeLeast Squares
∑xy ∑x ∑y
∑x^2 ∑x
Function
Programming
Meeting #8
The slopeLeast Squares
xΣ
SummationArray Float
Programming
Meeting #8
The slopeLeast Squares
xΣ for ine x
end
sum = 0.0
sum = sum + e
Programming
Meeting #8
The slopeLeast Squares
xΣ for ine array
end
sum = 0.0
sum = sum + e
def
end
return sum
Summation ( )array
Programming
Meeting #8
The slopeLeast Squares
Summation( )
x = [1.0, 2.0, 3.0, 4.0, 5.0]
y = [1.3, 1.8, 2.8, 2.5, 3.9]
x 15.0
xΣ
Summation(
Programming
Meeting #8
The slopeLeast Squares
x = [1.0, 2.0, 3.0, 4.0, 5.0]
y = [1.3, 1.8, 2.8, 2.5, 3.9]
y 12.3)
Σy
Programming
Meeting #8
The slopeLeast Squares
x = [1.0, 2.0, 3.0, 4.0, 5.0]
y = [1.3, 1.8, 2.8, 2.5, 3.9]
def Summation(array)
sum = 0.0
for e in array
sum = sum + e
end
return sum
end
Programming
Meeting #8
n xy x y
n x x2
2
α
( )
=
Σ −Σ Σ
Σ − Σ
The slopeLeast Squares
Σx2
∑x ∑y
∑x
Programming
Meeting #8
The slopeLeast Squares
Σx2 for ine array
end
sum = 0.0
sum = sum + e
def
end
return sum
Summation2 ( )array
**2
Programming
Meeting #8
The slopeLeast Squares
xyΣn xy x y
n x x2
2
α
( )
=
Σ −Σ Σ
Σ − Σ
∑x ∑y
∑x∑x^2
Programming
Meeting #8
The slopeLeast Squares
xyΣ
x = [1.0, 2.0, 3.0, 4.0, 5.0]
y = [1.3, 1.8, 2.8, 2.5, 3.9]
* * * * *
1.3 3.6 8.4 10.0 19.5
42.8
Programming
Meeting #8
The slopeLeast Squares
xyΣ for in
Programming
Meeting #8
The slopeLeast Squares
xyΣ while
sum = 0.0
i = 0
i < x.length
sum = sum + x[i] * y[i]
i = i + 1
end
The number
of elements in x
Programming
Meeting #8
The slopeLeast Squares
xyΣ while
sum = 0.0
i = 0
i < x.length
sum = sum + x[i] * y[i]
i = i + 1
end
in other languages
for (i = 0; i < x.length; i++) {
sum = sum + x[i] * y[i];
}
keep in
mind…
Programming
Meeting #8
The slopeLeast Squares
xyΣ while
sum = 0.0
i = 0
i < x.length
sum = sum + x[i] * y[i]
i = i + 1
end
def SumXY(x, y)
end
return sum
n xy x y
n x x2
2
α
( )
=
Σ −Σ Σ
Σ − Σ
∑x ∑y
∑x^2 ∑x
Programming
Meeting #8
The slopeLeast Squares
∑xy
Programming
Meeting #8
The slopeLeast Squares
(n*SumXY(x,y) - Summation(x) * Summation(y))
/
(n*Summation2(x) - Summation(x)**2)
n xy x y
n x x2
2
α
( )
=
Σ −Σ Σ
Σ − Σ
∑xy ∑x ∑y
∑x^2 ∑x
Programming
Meeting #8
Least Squares
n
x.length
y.length
or
The slope
Array.length
The number
of elements
in Array
Programming
Meeting #8
y x
n
β
α
=
Σ − Σ
The slope
Least Squares The y-intercept
(Summation(y) - a*Summation(x)) / n
Programming
Meeting #8
What's next?
Programming
Meeting #8
What's next?
Practice
Programming
Meeting #8
Questions
Programming
Meeting #8
Thank you for Meeting!

More Related Content

What's hot (20)

DOCX
New microsoft office word document (2)
Syed Umair
 
PDF
Recursion concepts by Divya
Divya Kumari
 
PDF
Equation plane
cmnell
 
PDF
Tech day ngobrol santai tensorflow
Ramdhan Rizki
 
DOCX
Simulate elliptical orbit in pygame
Dr Anurekha R
 
PDF
Stack concepts by Divya
Divya Kumari
 
DOCX
Simulate bouncing ball in pygame
Dr Anurekha R
 
PPTX
Advanced Concepts in Python
Saraswathi Murugan
 
PDF
Matlab file
rampal singh
 
PDF
Math 3-H6
jjlendaya
 
PDF
Lesson 1 Feb 10 2010
ingroy
 
DOCX
Public class arithmetic operatordemo
Cliff Rodrigo
 
PDF
Program implementation and testing
abukky52
 
PPTX
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
AAKASH KUMAR
 
DOC
Ramco C Question Paper 2003
ncct
 
PPTX
Tic tac toe game with graphics presentation
Prionto Abdullah
 
PPT
Roots T
bwlomas
 
PDF
10CSL67 CG LAB PROGRAM 4
Vanishree Arun
 
PDF
Polar plots with R
Andrija Djurovic
 
PPTX
Sketching derivatives
ssuserdb91c91
 
New microsoft office word document (2)
Syed Umair
 
Recursion concepts by Divya
Divya Kumari
 
Equation plane
cmnell
 
Tech day ngobrol santai tensorflow
Ramdhan Rizki
 
Simulate elliptical orbit in pygame
Dr Anurekha R
 
Stack concepts by Divya
Divya Kumari
 
Simulate bouncing ball in pygame
Dr Anurekha R
 
Advanced Concepts in Python
Saraswathi Murugan
 
Matlab file
rampal singh
 
Math 3-H6
jjlendaya
 
Lesson 1 Feb 10 2010
ingroy
 
Public class arithmetic operatordemo
Cliff Rodrigo
 
Program implementation and testing
abukky52
 
QUEUE || FUNCTION WRITING BASED ON QUEUE || LINKED LIST || DATA STRUCTURE || ...
AAKASH KUMAR
 
Ramco C Question Paper 2003
ncct
 
Tic tac toe game with graphics presentation
Prionto Abdullah
 
Roots T
bwlomas
 
10CSL67 CG LAB PROGRAM 4
Vanishree Arun
 
Polar plots with R
Andrija Djurovic
 
Sketching derivatives
ssuserdb91c91
 

Similar to Programming meeting #8 (11)

PDF
Programming meeting #7
Hideyuki Tabata
 
PPT
Introduction to matlab
krishna_093
 
PDF
Week8
Rich Price
 
PDF
21221
inKFUPM
 
PDF
Palm ch1
Heera Rawat
 
PPTX
Intro to matlab
Norhan Mohamed
 
PPT
1020 sas實習課
Kai Chun Cheng
 
DOC
20100528
byron zhao
 
DOC
20100528
byron zhao
 
PPTX
1025 sas實習課
Kai Chun Cheng
 
PPTX
1025 sas實習課
Kai Chun Cheng
 
Programming meeting #7
Hideyuki Tabata
 
Introduction to matlab
krishna_093
 
Week8
Rich Price
 
21221
inKFUPM
 
Palm ch1
Heera Rawat
 
Intro to matlab
Norhan Mohamed
 
1020 sas實習課
Kai Chun Cheng
 
20100528
byron zhao
 
20100528
byron zhao
 
1025 sas實習課
Kai Chun Cheng
 
1025 sas實習課
Kai Chun Cheng
 
Ad

Recently uploaded (20)

PPTX
sunil mishra pptmmmmmmmmmmmmmmmmmmmmmmmmm
singhamit111
 
PPTX
filteration _ pre.pptx 11111110001.pptx
awasthivaibhav825
 
PPTX
Introduction to Fluid and Thermal Engineering
Avesahemad Husainy
 
PPTX
ENSA_Module_7.pptx_wide_area_network_concepts
RanaMukherjee24
 
PDF
2025 Laurence Sigler - Advancing Decision Support. Content Management Ecommer...
Francisco Javier Mora Serrano
 
PPTX
Sensor IC System Design Using COMSOL Multiphysics 2025-July.pptx
James D.B. Wang, PhD
 
PDF
SG1-ALM-MS-EL-30-0008 (00) MS - Isolators and disconnecting switches.pdf
djiceramil
 
PDF
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
PDF
7.2 Physical Layer.pdf123456789101112123
MinaMolky
 
PPTX
ETP Presentation(1000m3 Small ETP For Power Plant and industry
MD Azharul Islam
 
PPTX
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
PPTX
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
PDF
CFM 56-7B - Engine General Familiarization. PDF
Gianluca Foro
 
PPTX
00-ClimateChangeImpactCIAProcess_PPTon23.12.2024-ByDr.VijayanGurumurthyIyer1....
praz3
 
PPTX
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
PDF
Machine Learning All topics Covers In This Single Slides
AmritTiwari19
 
PPTX
Unit 2 Theodolite and Tachometric surveying p.pptx
satheeshkumarcivil
 
PDF
CAD-CAM U-1 Combined Notes_57761226_2025_04_22_14_40.pdf
shailendrapratap2002
 
PDF
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
PPTX
Basics of Auto Computer Aided Drafting .pptx
Krunal Thanki
 
sunil mishra pptmmmmmmmmmmmmmmmmmmmmmmmmm
singhamit111
 
filteration _ pre.pptx 11111110001.pptx
awasthivaibhav825
 
Introduction to Fluid and Thermal Engineering
Avesahemad Husainy
 
ENSA_Module_7.pptx_wide_area_network_concepts
RanaMukherjee24
 
2025 Laurence Sigler - Advancing Decision Support. Content Management Ecommer...
Francisco Javier Mora Serrano
 
Sensor IC System Design Using COMSOL Multiphysics 2025-July.pptx
James D.B. Wang, PhD
 
SG1-ALM-MS-EL-30-0008 (00) MS - Isolators and disconnecting switches.pdf
djiceramil
 
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
7.2 Physical Layer.pdf123456789101112123
MinaMolky
 
ETP Presentation(1000m3 Small ETP For Power Plant and industry
MD Azharul Islam
 
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
CFM 56-7B - Engine General Familiarization. PDF
Gianluca Foro
 
00-ClimateChangeImpactCIAProcess_PPTon23.12.2024-ByDr.VijayanGurumurthyIyer1....
praz3
 
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
Machine Learning All topics Covers In This Single Slides
AmritTiwari19
 
Unit 2 Theodolite and Tachometric surveying p.pptx
satheeshkumarcivil
 
CAD-CAM U-1 Combined Notes_57761226_2025_04_22_14_40.pdf
shailendrapratap2002
 
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
Basics of Auto Computer Aided Drafting .pptx
Krunal Thanki
 
Ad

Programming meeting #8