Skip to main content

Exercises 28.5 Homework

1.

A power law is a function of the form \(y = a x^p\text{.}\) By taking logarithm on both sides we get \(\log y = p \log x + \log a\text{,}\) which is a linear function of \(\log x\text{.}\) So, to fit a power law to given data \((x_k, y_k)\text{,}\) we apply the logarithm to both \(x_k\) and \(y_k\text{,}\) and follow the linear regression process. Try this with France Covid data Example 28.1.1. Does the power law fit better or worse than exponential? (Compare visually, on the basis of plots.)

2.

The number of active Covid cases at SU during October 1-23, 2020, is given below.

y = [5 5 4 5 9 25 45 65 77 87 87 89 97 101 90 74 57 26 20 13 12 12 13]'; 

The x-values can be x = (1:23)'. Try to fit a “bell-shaped” Gaussian function \(y = \exp(Ax^2+Bx+C)\) (where \(A\lt 0\)) to the data. This can be done by the logarithmic transformation yt = log(y) followed by fitting a quadratic function to yt. Fit a quadratic function by solving a system with the matrix X = x.^(0:2), without weights. Having found the parameters beta, we get a suitable function f = @(x) exp(x.^(0:2)*beta) which should be plotted together with the data points.