Chapter 3 Graphics Mathematics - PowerPoint PPT Presentation

1 / 77
About This Presentation
Title:

Chapter 3 Graphics Mathematics

Description:

Computer graphics needs mathematics to enable the depiction of points, lines and ... One measure of Goodness of Outfit of the straight line to the points is the ... – PowerPoint PPT presentation

Number of Views:278
Avg rating:3.0/5.0
Slides: 78
Provided by: ahmed8
Category:

less

Transcript and Presenter's Notes

Title: Chapter 3 Graphics Mathematics


1
Chapter 3Graphics Mathematics
  • Computer graphics needs mathematics to enable the
    depiction of points, lines and other objects on
    the computer screen and through the printer or
    plotter.

2
  • A point is a position on a plane or in space.
  • Graphics involves first,
  • the location of points
  • next, the surfaces as bounded by lines
  • finally the representation of solids as bounded
    by surfaces.
  • The point itself is just the location and it has
    no size.

3
  • A line is a set of points. It is theoretically
    made up of an infinite number of points because
    it is a finite length divided by zero- the
    theoretical length of the point.
  • But in a computer, the smallest dot that can be
    displayed on the screen is a pixel, usually
    rectangular in shape. This has finite dimensions,
    however small. Hence, a computer line is made up
    of a finite number of dots.

4
  • On this basis, computer graphics involves various
    branches of mathematics in its development,
    implementation, and interpretation.
  • The range of the mathematics spans simple algebra
    and geometry to very sophisticated differential
    and integral calculus.

5
Coordinate System
  • All graphics, whether manual or computer,
    involves a reference point called the origin, and
    linear or angular distances measured along one or
    more reference directions called the coordinates,
    a base line along which distances are measured
    and from which angles are measured is called an
    axis. The origin and axes together are called
    Coordinate Systems.
  • The system of coordinates that will be used by
    computer to display images on the screen or to
    plot them on paper will be different from the
    standard Cartesian (x, y, z) or other World
    Coordinates in which we locate and describe real
    world objects or our own pictorial
    representations.

6
  • The following coordinate systems are commonly
    used to depict images in two dimensions (2D) on a
    plane, as on paper or on a screen, or in three
    dimensions (3D) in space, as a solid prototype
    (real-life object) or its model.
  • Two-Dimensional Cartesian (x, y)
  • Polar (r, ?)
  • Three-Dimensional Cartesian (x, y, z)
  • Cylindrical (r, ?, z)
  • Spherical (r, ?, ?)

7
Basic Mathematical Concepts
  • To get a computer to draw a circle would be a
    stupendous task-because computers cannot see or
    think in the sense that humans can.
  • In general, everything we draw with a computer
    has to be represented by means of dots (pixels)
    totaling tens of thousands, even millions. Their
    individual locations are entered, or scanned from
    an existing picture, or calculated by formulas
    from a few key data, and are connected by special
    line-drawing algorithms.

8
  • With improvements in hardware technology and
    software engineering, more and more of this
    computational labour is being built-in as part of
    the computer hardware and software.
  • For instance, it is quite easy these days to let
    the computer draw the circle and the straight
    line on the monitor, and then digitize (determine
    in terms of numbers) the coordinates of the
    intersection point or points and output their
    values.

9
  • However, even to use the sophisticated computer
    graphic capabilities available, the user of
    graphics software should have a sense of form and
    shape should know the physical configuration and
    be able to draw at least a freehand sketch of the
    object to be drawn, which implies a good
    understanding of its geometrical relationships.

10
  • Thus, in the application and programming of
    geometrical principles and techniques for
    computer graphics, knowledge and even some
    experience with geometry (locations) and topology
    (their spatial relationships) are essential. In
    addition, a basic understanding of the
    mathematics underlying computer graphics will be
    a definite plus.
  • A lot of analytical geometry and trigonometry is
    used in computer graphics.

11
Cubic Splines
  • Equation for Cubic splines
  • Splines are smooth curves passing through a given
    set of points. They are essential and convenient
    substitutes to the French Curves (plastic
    templates used to draw curves) which was so
    essential to manual drafting.
  • Cubic splines are popular because
  • they are fairly simple to compute
  • provide continuity of the curve
  • its slope
  • its curvature at a point (i.e. 2nd derivative)

12
  • Any curve may be built up of a series of cubic
    segments.
  • The general equation for the most basic (natural)
    2-dimensional cubic spline is
  • y a0 a1 . x a2 . x2 a3 . x3
  • We need 4 boundary conditions to evaluate the 4
    unknown constants a0, a1, a2, and a3.

13
  • These may be 4 points through which the curve
    must pass
  • three points and the slope at any one of them
    or,
  • as is common, the locations of the two end points
    and the slopes at these end points.
  • Occasionally, the curvature at a point may also
    be specified.
  • The slope equation is
  • y dy/dx a1 2a2 . x 3a3 . x2
  • The curvature equation is
  • y d2y/dx2 2a2 . x 6a3 . x
  • For single segment we will have 4 boundary
    conditions and the solution may be quite
    straightforward.

14
Example
  • Determine the equation for a cubic spline segment
    passing through 2 end points A(0,5) and B(10,20),
    having slope of 2 and curvature of 0.5 at A.

15
Solution
  • At A,
  • with x 0, y 5 ? y 2, and y -0.5, we
    have
  • 5 a0, from the cubic spline equation
  • 2 a1, from the 1st derivative
  • -0.5 2 a2, or a2 -0.25
  • At B,
  • with x 10, and y 20, we have
  • 20 5 2(10) 0.25(102) a3(103) or, a3
    0.02
  • Thus the desired cubic is y 5 2x 0.25x2
    0.02x3, and with the equation now available, as
    many points as needed for graphic representation
    may be computed.

16
Parametric Form
  • The parametric form of the cubic spline will be
    as follows
  • x a0 a1 . u a2 . u2 a3 . u3 (a)
  • y b0 b1 . u b2 .u2 b3 . u3 (b)
  • where, the parameter u will vary between
    specified min. and max. values to cover the
    desired range of the curve.

17
Concatenation of Multiple Cubic Spline Segments
  • To concatenate (to attach smoothly) a number of
    cubic spline segments making up curve passing
    through a series of n points, we need to insert
    (n1) cubic spline segments, requiring the
    evaluation of 4(n 1) coefficients.
  • The value of y at the 2 end points each of the
    (n1) segments yield 2(n 1) equations.
  • We may specify the slopes y at the first and the
    last points, giving 2 more equations.
  • This still leaves 4(n 1) 2(n 1) 2, or
    2(n 2) boundary conditions to be specified,
    which may conveniently be obtained as the
    matching of slope y and curvature y at the (n
    2) internal points, blending the successive
    segments smoothly with one another.

18
  • The computations get pretty tedious for more than
    a few points, and many computerized numerical
    analysis techniques such as parameterization,
    normalization, tri-diagonalization, and other
    matrix manipulations are invoked for faster and
    more efficient computation.
  • There are thus many formulations of the
    technique, but the basic principles are the same.

19
Example
  • Let us consider a first-order cubic spline made
    up from 2 segments AB and BC, through the 3
    points A(0,10), B(10,20), and C(20,30), with
    slopes of 1 at A and 1 at C.
  • meaning that the curve and slope are continuous

20
  • Let the segments AB and BC respectively have the
    equations
  • y a0 a1 . x a2 . x2 a3 . x3 (1)
  • and y b0 b1 . x b2 . x2 b3 . x3
    (2)
  • Then the corresponding slope equations are
  • y a1 2a2 .x 3a3 . x2 (3)
  • and y b1 2b2 .x 3b3 . x2 (4)

21
  • The corresponding curvature equations are
  • y 2a2 6a3 . x (5)
  • and y 2b2 6b3 . x (6)
  • For segment AB, we have
  • at A, with x 0, and y 10, and y -1, we
    have
  • a0 10 from (1)
    (6.5)
  • a1 -1 from (3 )
    (6.6)
  • at B, with x 10, and y 20, we have
  • a0 10a1 100a2 1000a3 20 (7)
    from (1)

22
  • For segment BC, we have
  • at B, with x 10, and y 20, we have
  • b0 10b1 100b2 1000b3 20 (8)
    from (2)
  • at C, with x 20, y 30, and y 1, we have
  • b0 20b1 400b2 8000b3 30 (9)
    from (1)
  • b1 2(20)b2 3(400)b3 1 (10) from
    (2)

23
  • Matching slopes at B (x 10) from segments AB
    and BC, from Eqs. (3 4), we get
  • a1 2(10)a2 3(100)a3 b1 2(10)b2 3(100)b3
    (11)
  • Matching curvatures at B (x 10) from segments
    AB and BC, from Eqs. (5 6), we get
  • 2a2 6(10)a3 2b2 6(10)b3 (12)

24
  • Equations (6.5 to 12) represent 8 simultaneous
    equations in the 8 unknowns a0, a1, a2, a3, b0,
    b1, b2, and b3.
  • The first two explicitly known (because xA 0),
    and hence we actually have only 6 equations in 6
    unknowns.
  • They can be solved one way or another (even
    longhand in this case), and the results are
  • a0 10
  • a1 -1
  • a2 0.35
  • a3 -0.015
  • b0 -10
  • b1 5
  • b2 -0.25
  • b3 0.005

To solve this linear system you may use the fact
that x inv(a).b
25
  • Thus, equations to the two segments AB and BC,
    satisfying the boundary conditions are
  • y 10 x 0.35x2 0.015x3 (13)
  • y -10 5 x - 0.25x2 0.005x3 (14)
  • With the equations now available, the two curve
    segments may be plotted. The end slopes are shown
    as broken lines.
  • The corresponding slope equations for AB and BC
    are
  • y -1 0.7x 0.045x2 (15)
  • y 5 0.5x 0.015x2 (16)
  • The corresponding curvature equations for AB and
    BC are
  • y 0.7 0.09x (17)
  • y -0.5x 0.03x (18)

26
(No Transcript)
27
  • By substitution of appropriate x values in Eqs.
    (13) and Eqs. (15), it may be confirmed that all
    the 6 specified boundary conditions Eqs. (7 to
    12) are satisfied.
  • The slope and curvature matching conditions at B
    (at x 10), Eqs. (11 12), can also be
    confirmed from Eqs. (15 16) and Eqs. (17 18),
    with the common slope being 1.5, and the common
    curvature being 0.2.

28
Assignment 2
  • 1. Tabulate five points for each segment to plot
    the two-segment cubic spline passing through
    A(5,5), B(15,10), and C(20,80).
  • Assume
  • Slopes at A and C as -1 and 1
  • Points P(10,12) and Q(25,2).

29
Bezier Curves
  • Bezier Curve Characteristics
  • In the late 1960s a French engineer, Pierre
    Bezier developed a method of fitting a polynomial
    curve of degree (n 1) to follow (not pass
    through) a set of n control points.
  • The first curve (in the following figure)
    controlled by 3 points is a quadratic.

30
(No Transcript)
31
  • The second and third curves (in the previous
    figure) are both cubics, but while in the second,
    the 2 intermediate points (2 and 3) are on the
    same side of the straight line connecting the
    first and last points (1 and 4), in the second
    figure they are on opposite sides of the line.

32
The characteristic features of these curves are
  • The curve passes through only the first and the
    last point.
  • At the 2 ends the curve is tangential to the
    chords joining the first and second point and the
    last and penultimate point.
  • The intermediate control points, through which
    the curve does not pass in general, are effective
    in pulling the curve in directions and in
    magnitudes we desire.
  • The shape of the curve is that of a convex hull
    (a shipping term) within the lines bounding it,
    and bulging towards the intersections of the
    lines.
  • Bezier curves may be made to close or even cross
    over, by appropriate choice of the control points.

33
  • These features of Bezier curves make them
    exceptionally useful in the design of imaginative
    and innovative geometric designs for cars,
    planes, architectural shapes, etc.
  • Most CAD packages and many utility packages that
    include a graphics module provide a means for the
    interactive development of Bezier curves.

34
  • Example of the Bezier curve is the MS-Windows
    Paintbrush (or Paint) module. It has an icon,
    which shows a general snake shaped curve, by
    clicking on which a 4-point Bezier curve may be
    drawn, as follows
  • a. Click on the icon
  • b. Click on the display space, at the location of
    Point 1 and Point 4. A straight line is shown
    connecting these 2 points.

35
(No Transcript)
36
  • Move to Control point 2, the location to which we
    wish to pull the curve and click the left button.
    This can be done by moving the cursor to the
    desired position, as displayed in the coordinates
    field on the screen. Alternatively, it may be
    done by trial and error, pressing the left button
    and continuing to move the mouse, with the curve
    also moving and changing shape, until the curve
    shape is visually satisfactory.
  • d. Move the mouse to the location Control
    Point 3 and click to complete the curve.

37
Equations for Bezier CurvesUsing Parametric Form
  • Let the four control points be
  • (x1, y1), (x2, y2), (x3, y3) and (x4, y4).
  • Then
  • x x(u) x1(1-u)3 3x2 u(1-u)2 3x3 u2(1-u)
    x4 u3
  • y y(u) y1(1-u)3 3y2 u(1-u)2 3y3 u2(1-u)
    y4 u3

38
Example
  • Generate a Bezier curve to the 4 control points
    (60,20), (80,100), 150,90) and (180,50).

39
Solution
  • x 60(1-u)3 3(80)u(1-u)2 3(150)u2(1-u)
    (180)u3
  • ? x 60 60u 150u2 90u3
  • y 20(1-u)3 3(100)u(1-u)2 3(90)u2(1-u)
    50u3
  • ? y 20 240u - 270u2 60u3
  • Now we will be able to generate as many points as
    are necessary to define the curve for plotting or
    other purposes, by assigning various values of
    parameter u ranging from 0 to 1.
  • The following table shows the computed values for
    u from 0 to 1, in increments of 0.1. An actual
    plot would require points at much smaller u
    intervals so that no two successive values are
    more than one pixel dimension apart.

40
Assignment 3 Write a program that generates u
automatically and calculates x and y.
41
  • The four control points are shown in the
    following figure, with broken lines joining them.
    It is clear that the first and last (third) lines
    are tangential to the curve.

42
Concatenation of Multiple Bezier Curve Segments
  • Bezier Curve segments also may be concatenated
    like cubic spline segments but the conditions at
    the junction of the Bezier segments are easier to
    satisfy and further, changes in one segment
    affect only the adjacent segment and not all the
    segments as in cubic splines.
  • If to a Bezier segments 'A' it is required to
    attach another segment 'B', all that is needed to
    be done is the following
  • Make the last point of the curve A the first
    point of curve B, that is, B1 A4. That is
  • xB1 xA4 and yB1 yA4

43
  • 2. Make the slope of the first chord B1-B2 of
    curve B the same as the slope of the last chord
    A3-A4 of curve A.
  • This condition, combined with the first,
    implies that B2 may be anywhere along the
    extension of the line A3-A4. This is easily
    accomplished by setting B2 away from B1 (A4) by
    a constant p times the x and y offsets by which
    A4 is away from A3.
  • That is
  • xB2 xB1 p(xA4 xA3 ) xA4( 1 p) p .
    xA3
  • yB2 yB1 p(yA4 yA3 ) yA4( 1 p) p .
    yA3

44
  • The following figure illustrates the location of
    B2 with the same slope as A3-A4, x and y standing
    for the respective projections of A3-A4.
  • The two stipulations fix the starting point (B1)
    of curve B and the direction of B1-B2, leaving
    the location of B2 along B1-B2, as well as the
    location of B3, for the user to manipulate to get
    the desired curve.
  • Usually the ending point (B4) is fixed from other
    considerations.
  • Obviously the actual curve will depend upon the
    exact location of B2, even with the same slope as
    A3-A4.

45
  • Figure 3.5(b) shows four different curves for
    four values of p. (The same principles may be
    extended to curves with more than 4 control
    points).

46
ExampleMultiple Segment Bezier Curve
  • In this figure Bezier curves have to be fitted
    between the points (60,20), (180,50) and
    (300,80), with a hill between the first pair, and
    a continuous valley and a second smaller hill
    within the second pair.
  • Fig
  • Let us further assume that by trial and error,
    the user has picked control points 2 and 3 for
    the first curve (say A) as (80,100) and (150,90).
    This segment has already been developed in
    Section 3.4.3, and shown as in Fig. 3.6.

47
  • xB1 xA4 180
  • yB1 yA4 50
  • Hence B1 (180,50)
  • xB2 180( 11 ) 150 210,
  • yB2 50(11) 90 10
  • Hence B2 (210, 10)
  • The end point B4 is given as (300,80).
  • Now let us say that, by trial and error, we
    choose Point B3 as (250,150), raising the curve
    from a valley, which has been pulled down to y2
    of 10, to a hilly location above the end point
    with given y4 of 80.

48
  • Applying the same process as in the previous
    example to this segment B, we get
  • x 180(1-u)3 3(210) . u . (1-u)2 3(250) . u2
    (1-u) 300 . u3
  • 180 90u 30 u2
  • y 50(1-u)3 3(10). u . (1-u)2 3(150) . u2 .
    (1-u) 80 . u3
  • 50 120u 540u2 390u3
  • It is interesting, but not terribly worrisome,
    that the x equation does not have an x3 term.
    Now sufficient number of points may be computed
    for display of the second segment. This is left
    as an assignment 4.

49
Assignment 5Exercise 3.2
  • Tabulate 5 points for each segment to plot the
    3-segment A-B-C Bezier Curve with control points
    as follows
  • A1(5,12)
  • A2(10,5)
  • A3(15,24)
  • A4(18,17)
  • C1(29,14)
  • C2(31,20)
  • C3(35,22)
  • C4(40,15)
  • Choose p of 0.5.
  • Hint Get B3 and B4 by continuity conditions from
    C1 and C2.

50
REGRESSION ANALYSIS
  • In computer graphic representation of a curve, if
    we have the equation to the curve, or appropriate
    data to determine the curve exactly, then it is
    best to include the curve in the plot routine and
    let it compute as many pixel positions as it is
    necessary to plot.
  • However, in real life, most natural phenomena
    cannot be reduced to simple equations. We may
    have a large number of observations either from
    nature (such as the weather) or from the
    laboratory experiments (such as from controlled
    chemical reactions), which lead to a number of
    (x,y) data.

51
  • Plotting of these raw data will indeed be the
    best means of understanding and interpreting the
    findings in qualitative terms. On the other
    hand, frequently it becomes necessary to
    interpret these data in scientific terms, trying
    to find meaning and logic behind these
    variations, and to be able to interpolate missing
    data within the observed range, and/or
    extrapolate (predict) data outside the observed
    range of data.
  • This is done by a further statistical and
    mathematical treatment called Regression
    Analysis, leading to algebraic equations to fit
    the observed data and predict the interpolated or
    extrapolated behaviour. In such cases too,
    plotting of both the observed and predicted
    information would be the best means of analysis
    and further decisions.

52
Least Squares Fit
  • Let us consider n sets of (x,y) observations.
    When plotted, they may be almost on a straight
    line, so much so that we want (at least as a
    first approximation) to fit a straight line
    passing through them, as in the following figure,
    and then use the equation of the fitted straight
    line for interpolation and extrapolation.
  • Fig

53
  • The best-fit straight line is obtained when the
    sum of the squares of the deviations of the
    points (marked as e1 and e2 for points P1 and P2
    in the inset of the figure) from the straight
    line is the minimum, and hence the fit is called
    the least Squares Fit.
  • In the equation y m . x c for the best-fit
    straight line, the slope m and intercept c are
    given by
  • m n ? x y ( ? x ) ( ? y
    ) / D
  • and
  • c (? y ) (? x2 ) ( ? x ) ( ? x y ) / D
  • where D n ? x2 - (?x)2
  • The ? symbol indicating summation for i
    1,2,...,n, of quantities following the symbol.
  • Once the equation is determined, the interpolated
    or extrapolated value of x within or outside the
    range may be computed from y m . x c. In
    actual plotting, only the line will be plotted,
    but none of the data points.

54
  • One measure of Goodness of Outfit of the straight
    line to the points is the Coefficient of
    Correlation given by
  • When all the points are actually on a straight
    line, all the deviation e will be zero, and r
    will equal 1, representing a perfect fit. The
    closer r is to 1, the better is the
    representation of the group of points by the
    fitted straight line.

55
  • In the B.C. (Before Computer) era, many
    professionals who wanted to get a best fit
    straight line through a number of scattered
    points on regular graph paper, and, by eye
    judgment, moved a transparent plastic scale over
    the points to locate a give and take line
    (meaning they left as much gap between points on
    one side of the straight edge as on the other).
  • Most of the time, this quick and dirty method
    served as well as any mathematical procedure, at
    least for practical application!
  • Similar procedures and equations are available
    for parabolic and higher degree fits, but those
    get quite a bit more involved than justified in
    this introductory work.

56
ExampleStraight Line Fit
  • Fit straight line to the five points with
    observed (x,y) coordinates (2, 7.1) (3, 9.2) (4,
    10.8) (6, 15.2) and (7, 16.7) and estimate the
    values at x 5 and x 8.

57
Solution
  • Let us first look at the five points, with a
    straight line from the first to the last point
    for judging the deviations, as in the following
    figure.
  • Fig

58
  • They are almost on a straight line, but not
    quite, especially when we see them against the
    straight line drawn from the first to the last
    point (which will almost certainly be not the
    best-fit line!)
  • To fit the straight line, we compute the various
    quantities required and tabulate them in the
    following table.

59
(No Transcript)
60
  • ? m 1.948
  • c 3.230
  • giving the best-fit equation as
  • y 1.948x 3.230
  • The Coefficient of Correlation is
  • r 0.999
  • which is not bad at all!
  • From the developed equation, we get
  • for x 5 y 1.948
    3.230 12.970
  • and for x 8 y 1.948(8)
    3.230 18.814

61
  • The best fit-line is shown plotted in the right
    side of the previous figure, solid between P1 and
    P5 and broken beyond this range.
  • The visual slope (of nearly 45º) is not the true
    slope because of the difference in the x and y
    scales.
  • The best-fit line in (b) may appear to be the
    same as the check line in (a) shown connecting P1
    and P5. But in actuality, the slope and intercept
    of the check line could be shown to be 1.920 and
    3.26 as against the 1.948 and 3.23 of the
    best-fit line.
  • Exercise Try y values of 7, 9, 11, 15 and 17 for
    the given x-values and confirm that the least
    square equations (slide 53) lead to the
    equation y 2x 3, with an r of 1.0, a perfect
    fit.

62
Curves Transformable to Straight Lines
  • Certain standard curves as shown in the following
    figure may be transformed to straight-line
    equations by substitution of the variables x
    and/or y and possibly the constant also, with
    some appropriate functions of the variables. Then
    regression analysis may be applied to get the
    best-fit straight line to the transformed forms
    and reverse functions applied to the variables
    and constants to replace the given points with
    the best-fit functions.
  • Fig

63
  • First, the scattered points available are
    examined visually, and the one among the three
    curves given, which would approximate them best,
    is selected.
  • It must be remembered that the transformations
    work only with reference to the specific origins
    O indicated. The coordinates of the points may be
    given with reference to some other origin O'.
    Hence, before regression analysis equations can
    be applied, the origin and axes appropriate to
    the selected curve must be located, and the
    coordinates modified by the shifts amounts.
  • Occasionally, trial and error may be necessary
    and each time the coefficient of correlation r
    must be found the final choice of course will be
    the one with the r closest to 1.

64
  • A) y m/x c The equation is sketched in Fig
    (a). Vertically the two arms of the curve
    converge to the y axis. The broken line depicts
    the asymptote at y c to which both branches of
    the curve converge. The origin O has to be
    located with this in mind and if the curves do
    not extend far enough or only one branch is
    available some trial and error may be needed
    (especially for y-axis) to choose the best fit
    with the highest r.
  • Let x 1/x. Then the equation reads, y mx
    c, the standard form. Now regression analysis x
    and y gives m and c.

65
  • B) y c . ax , The equation is sketched in Fig.
    (b). The broken line shows the intercept of the
    curve with the y-axis. In case there is an
    additive constant d on the right hand side, trial
    and error for d are inevitable, to gather results
    on various best-fit lines, and pick the one with
    the highest r.
  • When we take logarithm of both sides, we get
  • Log y log c
    x. log a
  • Let y log y, c log c, and m log a.
  • Then the equations reads, y m.x c, the
    standard form to which Least Square Equation may
    be applied.
  • After the best-fit line has been found connecting
    the x and y, we get m and c. Then, we can
    simply revert back to (x,y) coordinates, by
    taking c exp (c), and, a exp (m). Note that
    for this analysis, y cannot take values lt 0
    unless clt0, in which case, signs may reversed on
    both sides to proceed further.
  • This technique by manual plotting of log y
    against x on Semi-Log graph paper, and eye
    fitting a best-fit straight line, used to be and
    continuous to be known as the Semi-Log Plot
    method. See the following figure.

66
  • fig

67
  • (c) y c . xm The equation is sketched in figure
    c.
  • The full line shows the curve when m is odd, and
    the broken line shows the curves ( for xlt0 ) when
    m is even. The origin O must be chosen at the
    horizontal tangent position, if available within
    the range of points.
  • When we take logarithms of both sides, we get
  • log y
    log c m. log x
  • Let y log y, c log c. and x log x.
  • Then the equation reads y m. x c, the
    standard form to which least square equation may
    be applied.
  • After the best-fit line has been found connecting
    x and y, we get m and c.
  • Then, we can simply revert back to ( x, y )
    coordinates by taking c exp (c)
  • Note that when m is not an integer, both x and y
    cannot take values lt0, and that the broken line
    and solid line portions for xlt0 in Fig. (c) are
    simply reflections of the curve in the first
    quadrant, about the horizontal axis and about the
    origin respectively.
  • This technique by manual plotting of log y on
    Log-Log graph paper and eye fitting a best-fit
    straight line, used to be known as the Log-Log
    Plot method. See the previous figure (b).

68
  • Example This sample of data obtained in a study
    of the relationship between the number of years
    that applicants for certain foreign service jobs
    have studied English in high school or college
    and the grades which they received in a
    proficiency test in that language

69
  • No. of years (x) Grade in Test (y) x2 x.y
  • 3 57 9 171
  • 4 78 16 312
  • 4 72 16 288
  • 2 58 4 116
  • 5 89 25 445
  • 3 63 9 189
  • 4 73 16 292
  • 5 84 25 420
  • 3 75 9 225
  • 2 48 4 96
  • 35 697 133 2,554

70
  • The goal is to find one line which fits the data.
  • Normal Equations
  • ?y na b?x n no. of pairs
  • ?xy a?x b ?x2
  • 697 10 a 35 b
  • 2,554 35 a 133 b

71
  • Two methods to find a and b
  • (1)
  • 1st 7 ? 4,879 70 a 245 b
  • 2nd 2 ? 5,108 70 a 266 b
  • ? (2nd 1st) 229 0 21 b
  • ? b 10.90 ? a 31.55
  • ? y 31.55 10.90 x

72
  • (2)
  • 1st 697 10 a 35 b
  • ? a (679 35b)/10
  • 2nd ? 2,554 35 (679 35b)/10 133 b
  • ? b 10.90 ? a 32.55

73
  • Where the slope of the line is given by m (Dx
    over Dy or the rise over the run) and the
    intercept of the y axis is given as b. For n
    data pairs, the equations used to find the slope
    m and intercept b are
  •  
  • 1.) b ( Sy Sx2 - Sx Sxy ) / ( n Sx2
    (Sx)2 )
  •  
  • 2.) m ( N Sxy SySx ) / (n Sx2 (Sx) 2 )
  •  

74
Assignment 6.1 (deadline Monday 13th Jan)
  • The following area data on the IQs of 25
    students, the number of hours they studies for a
    certain achievement test, and their scores on the
    test

75
(No Transcript)
76
  • 1. Use the computer to find the least squares
    line which will enable us to predict a student
    score on the test in terms of his/her IQ. And
    draw the line.
  • 2. Use the computer to find the least squares
    line which will enable us to predict a students
    score on the test in terms of the numbers of
    hours he/she studied for the test. And draw the
    line.
  • 3. Use the computer to predict how many hours a
    student will study for the test given his/her IQ.
    Draw the line.

77
Assignment 6.2 (deadline Monday 13th Jan)
  • Exercise 3.3 page 33
  • Fit the best straight line to the points (2,12),
    (3,15), (5,22) and (6,26) and hence predict y for
    x4 and x8.
Write a Comment
User Comments (0)
About PowerShow.com