kaygisiz2
18/04/2007, 18:14
Assignment Problem
Engineering Experiments and Function Discovery
In engineering we often make experiments to understand how a system behaves under varying conditions. These experiments produce a set of data points. The next step in understanding the
system would be to determine a formula
y f x that represents the behavior of the system.
This process is called “function discovery”. The formula that is discovered is called to be a
“good fit” if it goes close to the data points that are collected from the experiments.
Suppose that we are testing the braking performance of a new car. We run different experiments with varying speeds and find the stopping distances of the car as:
Speed
(km/h)
Stopping
Distance (m)
20 6.725
40 16.625
60 30.975
80 50.000
100 68.300
120 93.125
140 117.975
When we plot the data, we see how the stopping distance changes with respect to speed. The next step is to discover a formula that goes through these data points. For instance for this
data set,
y 0.9360x 20.07 represents the system as shown in the figure.
Stopping Distances for Varying Speeds
140
y = 0.9360x - 20.07
120
100
80
60
40
20
0
-20
0 20 40 60 80 100
Speed (km/h)
120 140
160
In other words, we can use the function
y 0.9360 x 20.07
for predicting the stopping
distance of the car at 35 km/h although we did not have an experiment that was made for this speed.
The Least Squares Approximation
In this assignment, we are going to use the least squares method to find a line that goes through a given set of data points. The least squares approximation to a set of data points can
where N is the number of data points and A and B are the coefficients of a line that passes
through the data points with least error:
y Ax B
(2)
Now let’s solve together the least squares approximation for the stopping distance data. The
N
xk
term in the first equation above is the square of all x values (speeds in this case) added
k 1
up. This sum is 56000. Make sure you do it yourself with the help of a calculator and get the same result. When we find all other terms in the equations we get:
56000 A 560B 41179.5
560 A 7 B 383.7
(3)
Calculate the rest of the terms as well and verify these equations of two unknowns.
Solving these two equations together, we find:
A 0.9360
B 20.07
(4)
Make sure you do all of these calculations yourself and understand them before proceeding to
Part 1.
PART 1:
Write a program that reads in the data points line by line. That is, the user will give the first pair of x and y values, press enter, give the second pair of x and y values, press enter, and so on. The user will press -1 for both x and y values to stop entering data.
Your program will find and display the two linear equations in terms of A and B (like equation 3 above).
PART 2:
Write a new program that reads in the coefficients for two linear equations of two unknowns and solves them. For instance when the user enters the coefficients in equation 3 as:
56000 560 41179.5
560 7 383.7
Your program will find and display the values of A and B as in equation 4.
PART 3:
Combine PART 1 and PART 2 to find the least squares approximation line for any given set
of data points.
You will only upload your code for PART 3 in this assignment.
TAM OLARAK GRAFIK VEDE FORMULLERI GORMEK İÇİN: http://rapidshare.com/files/26478657/C.doc
YUKARIDADA AÇIKLANDIĞI GİBİ BİR ÖDEVİM VAR C KODU İLE YAZMAM GEREKEN FAKAT NEKADAR UĞRAŞTIYSAM BASINDAN BILE BAŞLAYAMADIM YAZMAYA. ÖDEVİ YAPARKEN ARRAY DE KULLANMAM LAZIM.YUKARIDAKI ACIKLAMADAKI PROGRAMI NASIL YAPABILICEGIM HAKKIDNA BILGI VERİRSENİZ SEVİNİRİM.YANİ AŞAMA AŞAMA NELER YAPMAM GEREKTİĞİNİ DÖYLERSENİZ BEN KODA DOKEBILRIM YARDIMALRINIZI BENDEN ESİRGEYEİN.
Engineering Experiments and Function Discovery
In engineering we often make experiments to understand how a system behaves under varying conditions. These experiments produce a set of data points. The next step in understanding the
system would be to determine a formula
y f x that represents the behavior of the system.
This process is called “function discovery”. The formula that is discovered is called to be a
“good fit” if it goes close to the data points that are collected from the experiments.
Suppose that we are testing the braking performance of a new car. We run different experiments with varying speeds and find the stopping distances of the car as:
Speed
(km/h)
Stopping
Distance (m)
20 6.725
40 16.625
60 30.975
80 50.000
100 68.300
120 93.125
140 117.975
When we plot the data, we see how the stopping distance changes with respect to speed. The next step is to discover a formula that goes through these data points. For instance for this
data set,
y 0.9360x 20.07 represents the system as shown in the figure.
Stopping Distances for Varying Speeds
140
y = 0.9360x - 20.07
120
100
80
60
40
20
0
-20
0 20 40 60 80 100
Speed (km/h)
120 140
160
In other words, we can use the function
y 0.9360 x 20.07
for predicting the stopping
distance of the car at 35 km/h although we did not have an experiment that was made for this speed.
The Least Squares Approximation
In this assignment, we are going to use the least squares method to find a line that goes through a given set of data points. The least squares approximation to a set of data points can
where N is the number of data points and A and B are the coefficients of a line that passes
through the data points with least error:
y Ax B
(2)
Now let’s solve together the least squares approximation for the stopping distance data. The
N
xk
term in the first equation above is the square of all x values (speeds in this case) added
k 1
up. This sum is 56000. Make sure you do it yourself with the help of a calculator and get the same result. When we find all other terms in the equations we get:
56000 A 560B 41179.5
560 A 7 B 383.7
(3)
Calculate the rest of the terms as well and verify these equations of two unknowns.
Solving these two equations together, we find:
A 0.9360
B 20.07
(4)
Make sure you do all of these calculations yourself and understand them before proceeding to
Part 1.
PART 1:
Write a program that reads in the data points line by line. That is, the user will give the first pair of x and y values, press enter, give the second pair of x and y values, press enter, and so on. The user will press -1 for both x and y values to stop entering data.
Your program will find and display the two linear equations in terms of A and B (like equation 3 above).
PART 2:
Write a new program that reads in the coefficients for two linear equations of two unknowns and solves them. For instance when the user enters the coefficients in equation 3 as:
56000 560 41179.5
560 7 383.7
Your program will find and display the values of A and B as in equation 4.
PART 3:
Combine PART 1 and PART 2 to find the least squares approximation line for any given set
of data points.
You will only upload your code for PART 3 in this assignment.
TAM OLARAK GRAFIK VEDE FORMULLERI GORMEK İÇİN: http://rapidshare.com/files/26478657/C.doc
YUKARIDADA AÇIKLANDIĞI GİBİ BİR ÖDEVİM VAR C KODU İLE YAZMAM GEREKEN FAKAT NEKADAR UĞRAŞTIYSAM BASINDAN BILE BAŞLAYAMADIM YAZMAYA. ÖDEVİ YAPARKEN ARRAY DE KULLANMAM LAZIM.YUKARIDAKI ACIKLAMADAKI PROGRAMI NASIL YAPABILICEGIM HAKKIDNA BILGI VERİRSENİZ SEVİNİRİM.YANİ AŞAMA AŞAMA NELER YAPMAM GEREKTİĞİNİ DÖYLERSENİZ BEN KODA DOKEBILRIM YARDIMALRINIZI BENDEN ESİRGEYEİN.