Skip to content
Snippets Groups Projects
Commit 0c1635ea authored by Erik Strand's avatar Erik Strand
Browse files

Partially answer 12.1

parent 1f02bb00
No related branches found
No related tags found
No related merge requests found
...@@ -47,8 +47,8 @@ int main() { ...@@ -47,8 +47,8 @@ int main() {
Eigen::MatrixXd mat(n_samples, 2); Eigen::MatrixXd mat(n_samples, 2);
for (uint32_t i = 0; i < n_samples; ++i) { for (uint32_t i = 0; i < n_samples; ++i) {
mat(i, 0) = samples[i]; mat(i, 0) = 1;
mat(i, 1) = 1; mat(i, 1) = samples[i];
} }
// Need at least ThinU and ThinV to use mat_svd.solve. // Need at least ThinU and ThinV to use mat_svd.solve.
......
...@@ -2,6 +2,19 @@ ...@@ -2,6 +2,19 @@
title: Problem Set 7 (Function Fitting) title: Problem Set 7 (Function Fitting)
--- ---
## 1
Generate 100 points $$x$$ uniformly distributed between 0 and 1, and let $$y = 2 + 3x + \zeta$$,
where $$\zeta$$ is a Gaussian random variable with a standard deviation of 0.5. Use an SVD to fit
$$y = a + bx$$ to this data set, finding $$a$$ and $$b$$. Evaluate the errors in $$a$$ and $$b$$
using equation (12.34), by bootstrapping to generate 100 datasets, and from fitting an ensemble of
100 independent data sets.
I used [Eigen](http://eigen.tuxfamily.org/index.php?title=Main_Page) to compute the SVD (in C++).
My code is
[here](https://gitlab.cba.mit.edu/erik/nmm_2020_site/-/tree/master/_code/pset_07/cpp/svd.cpp). I
found $$a = 2.10697$$ and $$b = 2.91616$$.
## 3 ## 3
{:.question} {:.question}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment