Completed: / exercises

HW2. Sensor Calibration

Due date: 2026-01-29 23:59.
Recommended Resources:

1D Sensor Calibration: Thermometer

In this part of the assignment, you will explore how sensor calibration can be expressed mathematically using linear algebra, the pseudoinverse, and the Singular Value Decomposition (SVD).

Problem Setup

Assume you have a simple thermometer that reports temperature in degrees Celsius. You measure the temperature on three consecutive days using:
Let:
r_1, r_2, r_3. \\\
s_1, s_2, s_3. \\\
You notice that the new thermometer consistently reports different values, so you assume it has a linear calibration error. You model this error using a scale-and-offset model:
\begin{aligned} s_1 &= a r_1 + b, \\ s_2 &= a r_2 + b, \\ s_3 &= a r_3 + b. \\\ \end{aligned}
In the above equations, the following calibration parameters are introduced:
Your goal is to find ๐‘Ž and ๐‘, so that you can effectively use the new thermometer by applying these calibration parameters to any future measurement. In practice, the data may not satisfy the calibration model exactly, so ๐‘Ž and ๐‘ are instead estimated using least squares.

Download Visualization Tool

Download and run the following visualization tool for understanding linear calibration using least-squares and SVD:
Calibration1D
This tool visualizes the calibration process and the solution to the least-squares minimization problem by animating the following:
\beta = \begin{bmatrix} a \\ b \end{bmatrix} \in \mathbb{R}^2. \\\
M \beta \in \mathbb{R}^3. \\\
s = \begin{bmatrix} s_1 \\ s_2 \\ s_3 \end{bmatrix} \in \mathbb{R}^3. \\\
\hat{\beta} = \begin{bmatrix} a \\ b \end{bmatrix}. \\\
\hat{\beta} = \arg\min_{\beta} || s - M \beta ||. \\\
\hat{s} = M \hat\beta \in \mathbb{R}^3. \\\
s - M \hat\beta. \\\

Question 1

Your first exercise is to put the calibration model into the matrix form. Start with the three calibration equations below:
\begin{aligned} s_1 &= a r_1 + b, \\ s_2 &= a r_2 + b, \\ s_3 &= a r_3 + b. \\\ \end{aligned}
You want to rewrite them in matrix form
s = M \beta, \\\
where the ground-truth temperature vector is
s = \begin{bmatrix} s_1 \\ s_2 \\ s_3 \end{bmatrix} \in \mathbb{R}^3, \\\
and the vector of calibration parameters is
\beta = \begin{bmatrix} a \\ b \end{bmatrix} \in \mathbb{R}^2. \\\
Which of the following is the correct data matrix?
\begin{aligned} \mathsf{A.}\;\; &M = \begin{bmatrix} r_1 & b \\ r_2 & b \\ r_3 & b \end{bmatrix} \\\ \\\ \mathsf{B.}\;\; &M = \begin{bmatrix} a & 1 \\ a & 1 \\ a & 1 \end{bmatrix} \\\ \\\ \mathsf{C.}\;\; &M = \begin{bmatrix} s_1 & 1 \\ s_2 & 1 \\ s_3 & 1 \end{bmatrix} \\\ \\\ \mathsf{D.}\;\; &M = \begin{bmatrix} 1 & r_1 \\ 1 & r_2 \\ 1 & r_3 \end{bmatrix} \\\ \\\ \mathsf{E.}\;\; &M = \begin{bmatrix} s_1 & a \\ s_2 & b \\ s_3 & 1 \end{bmatrix} \\\ \\\ \mathsf{F.}\;\; &M = \begin{bmatrix} r_1 & 1 \\ r_2 & 1 \\ r_3 & 1 \end{bmatrix} \\\ \\\ \mathsf{G.}\;\; & \text{None of the above.} \end{aligned}
Warning: You have not logged in. You cannot answer.

Question 2

Now consider a specific calibration experiment. Suppose the new (uncalibrated) thermometer reports the following temperatures:
r_1 = 0, r_2 = 1, r_3 = 2.5. \\\
The trusted thermometer reports the ground-truth temperatures:
s_1 = -2, s_2 = -1, s_3 = 0.5. \\\
Assume the same linear calibration model used above:
\begin{aligned} s_1 &= a r_1 + b, \\ s_2 &= a r_2 + b, \\ s_3 &= a r_3 + b. \\\ \end{aligned}
Refactor the equations to obtain the data matrix, and then use the Calibration1D visualization tool to estimate the calibration parameters using the pseudoinverse.
Which calibration parameters did the tool report?
Warning: You have not logged in. You cannot answer.

Question 3

Which of the following pairs of measurements and ground-truth values results in the best calibration, meaning the smallest residual vector magnitude?
Warning: You have not logged in. You cannot answer.

Question 4

Using the visualization tool, keep the data matrix ๐‘€ fixed and keep changing the ground-truth vector ๐‘ .
Which of the following quantities change as a result?
Warning: You have not logged in. You cannot answer.

Question 5

Suppose the new thermometer reports the same value for different ground truth values:
r_1 = r_2 = r_3 = 1, \,\,\,\, s_1 = 0.1, s_2 = 1.1, s_3 = 2.1. \\\
In this case, the data matrix has rank 1, not 2. One of the singular values of the matrix is zero. However, the pseudoinverse can still be computed analytically using the SVD-based formula:
๐‘€^{+} = Vฮฃ^{+} U^{\top} \\\
The visualization tool still computes the matrices U, ฮฃ, and V, but because ฮฃ contains a zero singular value, the tool cannot proceed with animation or estimation of calibration parameters. Therefore, you cannot rely on the visualization tool in this case and must reason analytically.
Compute the pseudoinverse of M manually, and determine the estimated ฮฒฬ‚ using the computed pseudoinverse. Which one is the resulting ฮฒฬ‚ , you can round the decimals?
Warning: You have not logged in. You cannot answer.

3D Sensor Calibration: Accelerometer

In this part of the assignment, you will extend the ideas from 1D thermometer calibration to the 3D calibration of an accelerometer.
An accelerometer measures acceleration along three orthogonal axes (๐‘ฅ, ๐‘ฆ, ๐‘ง). Due to manufacturing imperfections, the raw measurements typically contain scale errors, axis misalignment, and offset (bias) errors. Calibration is required to correct these errors before the sensor can be used reliably.
This calibration problem is a direct generalization of the 1D case. Instead of estimating two scalar parameters, you will now estimate a matrix of calibration parameters and an offset vector.

Sensor Data

Start by downloading raw acceleration measurements recorded by an uncalibrated accelerometer:
Each row corresponds to one accelerometer measurement and contains three values, representing the raw acceleration measured along the ๐‘ฅ, ๐‘ฆ, and ๐‘ง axes:
\begin{aligned} &\dots \\\ r_{xi},\; &r_{yi},\; r_{zi}\\\ &\dots \end{aligned} \\\
Next, download the file containing acceleration measurements obtained from a trusted reference system:
This file contains measurements in the same format:
\begin{aligned} &\dots \\\ s_{xi},\; &s_{yi},\; s_{zi}\\\ &\dots \end{aligned} \\\
Both files contain thousands of measurements, making the calibration problem highly overdetermined.

Calibration Model

We assume a linear calibration model that accounts for scale, cross-axis coupling, and offset errors. The calibration parameters consist of:
A = \begin{bmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \end{bmatrix} \qquad b = \begin{bmatrix} b_1 \\ b_2 \\ b_3 \end{bmatrix} \\\
The calibration model is:
s_i = A r_i + b, \qquad s_i = \begin{bmatrix} s_{xi} \\ s_{yi} \\ s_{zi} \end{bmatrix}, \qquad r_i = \begin{bmatrix} r_{xi} \\ r_{yi} \\ r_{zi} \end{bmatrix}. \\\
You can also re-write it component-wise for each pair of measurements ๐‘ แตข and ๐‘Ÿแตข:
\begin{aligned} & \dots\\ s_{xi} &= a_{11} r_{xi} + a_{12} r_{yi} + a_{13} r_{zi} + b_1 \\ s_{yi} &= a_{21} r_{xi} + a_{22} r_{yi} + a_{23} r_{zi} + b_2 \\ s_{zi} &= a_{31} r_{xi} + a_{32} r_{yi} + a_{33} r_{zi} + b_3\\ & \dots\\ \end{aligned} \\\
Your goal is to estimate the calibration parameters ๐‘จ and ๐‘ using least-squares.

Data Matrix Formulation

Your task is to refactor all calibration equations into a single linear system of the form:
s = M \beta \\\
where:
Because the number of measurements is much larger than the number of unknown parameters, this system is highly overdetermined and must be solved using the pseudoinverse.

Question 6

Which of the following correctly represents the vector of unknown calibration parameters for the 3D accelerometer, as described in lecture?
Warning: You have not logged in. You cannot answer.

Question 7

Which of the following correctly describes the size of the data matrix ๐‘€?
Warning: You have not logged in. You cannot answer.

Question 8

Using the two provided files (measurements.csv and groundtruth.csv), which of the following options correctly lists the first four rows of the data matrix ๐‘€?
\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \begin{aligned} \mathsf{A.}\; & {\scriptsize \begin{bmatrix} 0.44228 & -0.094418 & -12.6990 & 1 & 1 & 1 \\ 0.41223 & -0.77859 & -11.5290 & 1 & 1 & 1 \\ 0.21464 & -0.53937 & -9.6857 & 1 & 1 & 1 \\ -0.63297 & -0.84337 & -9.8479 & 1 & 1 & 1\\ \end{bmatrix} } \\\ \mathsf{B.}\; & {\scriptsize \begin{bmatrix} 0.44228 & 0 & 0 & -0.094418 & 0 & 0 & -12.6990 & 0 & 0 \\ 0 & 0.44228 & 0 & 0 & -0.094418 & 0 & 0 & -12.6990 & 0 \\ 0 & 0 & 0.44228 & 0 & 0 & -0.094418 & 0 & 0 & -12.6990 \\ 0.41223 & 0 & 0 & -0.77859 & 0 & 0 & -11.5290 & 0 & 0\\ \end{bmatrix} } \\\ \mathsf{C.}\; & {\scriptsize \begin{bmatrix} 0.44228 & -0.094418 & -12.6990 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0.44228 & -0.094418 & -12.6990 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0& 0 & 0.44228 & -0.094418 & -12.6990 & 1 \\ 0.41223 & -0.77859 & -11.5290 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\ \cdots&\cdots &\cdots &\cdots &\cdots & \cdots &\cdots &\cdots &\cdots & \cdots&\cdots & \cdots\\ \end{bmatrix} } \\\ \mathsf{D.}\; & {\scriptsize \begin{bmatrix} 1 & 0.44228 & -0.094418 & -12.6990 & 0 & 0 & 0 \\ 1 & 0.41223 & -0.77859 & -11.5290 & 0 & 0 & 0 \\ 1 & 0.21464 & -0.53937 & -9.6857 & 0 & 0 & 0 \\ 1 & -0.63297 & -0.84337 & -9.8479 & 0 & 0 & 0\\ \end{bmatrix} } \\\ \mathsf{E.}\; & {\scriptsize \begin{bmatrix} 0.44228 & -0.094418 & -12.6990 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0.44228 & -0.094418 & -12.6990 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0& 0.44228 & -0.094418 & -12.6990 \\ 0.41223 & -0.77859 & -11.5290 & 0 & 0 & 0 & 0 & 0 & 0 \\\ \cdots&\cdots &\cdots &\cdots &\cdots & \cdots &\cdots &\cdots &\cdots \\ \end{bmatrix} } \\\ \mathsf{F.}\; &\text{More than one above.}\\ \mathsf{G.}\; &\text{None of the above.} \end{aligned}
Warning: You have not logged in. You cannot answer.

Question 9

Using the two provided files (measurements.csv and groundtruth.csv), which of the following correctly represents the ground-truth vector ๐‘ ?
Warning: You have not logged in. You cannot answer.

Question 10

Using the two provided files (measurements.csv and groundtruth.csv), compute the estimated calibration parameters using pseudoinverse. You can pick any numerical tool you like (for example: Python, NumPy, MATLAB, or similar).
Report:
  • the estimated calibration matrix ๐‘จ,
  • the offset vector ๐‘,
  • and the tool or software used.
Report numerical values with reasonable precision (for example, 3โ€“4 significant digits).

Warning: You have not logged in. You cannot answer.

Authors

Anna LaValle.
?