How to Do a Linear Fit on CCDs

104 39
    • 1). Write the signal strengths (y) and their corresponding exposure times (x) as linear functions y = mx + b. Given the signals and exposures of 8.4 counts and 1 ms, 38.2 counts and 5 ms, 76.3 counts and 10 ms and 375.3 counts and 50 ms, for instance, write the following equations:

      1 = 8.4m + b

      5 = 38.2m + b

      10 = 76.3m + b

      50 = 375.3m + b

    • 2). Build a matrix "A" with two columns and rows for how many lines of data you have. Fill the matrix with the coefficients from the right side of the linear equations. Start with the coefficient for m and then move on to the coefficient for b. Repeat for each row. For example:

      [

      8.4, 1

      38.2, 1

      76.3, 1

      375.3, 1

      ]

    • 3). Create a column vector "B" with rows for how many lines of data you have. Fill it with the corresponding signal strengths. For example:

      [

      1

      5

      10

      50

      ]

    • 4). Establish a least squares vector "X*" and fill it with one instance of m* and one instance of b*. You will later calculate these to create the regression line. For example:

      [

      m*

      b*

      ]

    • 5). Transpose matrix "A" into the transpose "AT" by turning it from a #x2 matrix into a 2x# matrix. Given the example, transpose A from

      [

      8.4, 1

      38.2, 1

      76.3, 1

      375.3, 1

      ]

      into

      [

      8.4, 38.2, 76.3, 375.3

      1, 1, 1, 1

      ]

    • 6). Multiply matrix "AT" by matrix "A" into matrix (ATA) by using the dot-product method. For example:

      [

      8.4, 38.2, 76.3, 375.3

      1, 1, 1, 1

      ]

      *

      [

      8.4, 1

      38.2, 1

      76.3, 1

      375.3, 1

      ]

      =

      [

      8.4(8.4) + 38.2(38.2) + 76.3(76.3) + 375.3(375.3), 8.4(1) + 38.2(1) + 76.3(1) + 375.3(1)

      1(8.4) + 38.2(1) + 76.3(1) + 375.3(1), 1(1) + 1(1) + 1(1) + 1(1)

      ]

      or

      [

      148,201.58, 498.2

      498.2, 1

      ]

    • 7). Multiply matrix "AT" by vector "B" into matrix "ATB" by using the dot-product method. For example:

      [

      8.4, 38.2, 76.3, 375.3

      1, 1, 1, 1

      ]

      *

      [

      1

      5

      10

      50

      ]

      =

      [

      8.4(1) + 38.2(5) + 76.3(10) + 375.3(50)

      1(1) + 1(5) + 1(10) + 1(50)

      ]

      or

      [19,727.4

      66]

    • 8). Write two equations in the form y = mx + b by using the values of matrices/vectors "ATA," "ATB" and "X*." The first row of matrix "ATA" will correspond to the coefficients of m and b, respectively, for the first equation while the first row of "ATB" will correspond to the value on the other side of the equation. For example, the first equation would be 19,727.4 ("ATB" value, 1st row) = 148,201.58m ("ATA" value, 1st row, 1st column) + 498.2b ("ATA" value, 1st row, 2nd column).

      19,727.4 = 148,201.58m* + 498.2b*

      66 = 498.2m* + 1b*

    • 9). Solve for the least squares variable m* by using elimination. For example:

      19,727.4 = 148,201.58m* + 498.2b*

      66 = 498.2m* + 1b*

      Multiply the second equation by -498.2 to get:

      19,727.4 = 148,201.58m* + 498.2b*

      -32,881.2 = -248,203.24m* - 498.2b*

      --------------------------------------------------------

      -13,153.8 = -100,001.66m*

      m* = -13,153.8 / -100,001.66

      m* = .1315

    • 10

      Substitute the value of m* into one of the equations to solve for b*. For example:

      Substitute m = .1315 into 19,727.4 = 148,201.58m* + 498.2b*:

      19,727.4 = 148,201.58(.1315) + 498.2b*

      19,727.4 - 148,201.58(.1315) = 498.2b*

      238.89223 = 498.2b*

      238.89223 / 498.2

      .4795 = b*

    • 11

      Plug m* and b* into a standard line equation y = mx + b to finish creating a linear fit for your CCD data. For example:

      y = .1315x + .4795

Source...

Leave A Reply

Your email address will not be published.