Exercise 16.1.3

Exercise 16.1.3#

Question 1#

Implement the linear least squares solution for three variables to find the constants in the Cepheid variable functional relation:

\[ M = a_0 + a_1 \log P + a_2 (B - V) \]

using the same data file as before: ./data/cepheid_data.csv.

Answers:

  • \(a_0 = -2.15\) mag

  • \(a_1 = -3.12\) mag

  • \(a_2 = 1.49\)

Question 2#

Package the multivariate least squares solution into a function, taking the file path (and possibly the delimeter used as well as number of lines to skip) and return the \(\boldsymbol{A}\) matrix. Unlike in the case with the Cepheid variable data, you can assume that the first column of the file will contain \(y\) data and the rest \(x_j\) data.

Test your function on the data sets ./exercise-data/data02.csv and ./exercise-data/data03.csv.

Answers:

\[\begin{eqnarray*} \text{data02.csv} & \quad \quad \quad & \text{data03.csv}\\ \boldsymbol{A} = \begin{pmatrix} -0.402\\ 0.201\\ 1.222\\ 0.341\\ 0.134\\ \end{pmatrix} & \quad \quad \quad & \boldsymbol{A} = \begin{pmatrix} 2.81\\ 0.55\\ 1.63\\ 2.71\\ 1.33\\ -1.16\\ 2.39\\ 1.12\\ 0.65\\ 4.05\\ -2.81\\ \end{pmatrix}\\ \end{eqnarray*}\]

Question 3#

Solve the problems in Question 1 and 2, but now using \(\chi^2\) minimization. Use the same data sets with a relative uncertainty 10% for y ( \(\sigma = 0.1 y\)). Note that this may not produce better fits, as the data doesn’t necessarily agree with these uncertainties.

Answers for Question 1:

  • \(a_0 = -2.13\) mag

  • \(a_1 = -3.20\) mag

  • \(a_2 = 1.61\)

Answers for Question 2:

\[\begin{eqnarray*} \text{data02.csv} & \quad \quad \quad & \text{data03.csv}\\ \boldsymbol{A} = \begin{pmatrix} -0.216\\ 0.201\\ 1.214\\ 0.343\\ 0.132\\ \end{pmatrix} & \quad \quad \quad & \boldsymbol{A} = \begin{pmatrix} 3.680\\ 0.549\\ 1.514\\ 2.706\\ 1.332\\ 1.172\\ 2.400\\ 1.252\\ 0.638\\ 4.046\\ -2.813\\ \end{pmatrix}\\ \end{eqnarray*}\]