7 Parameters for functions
The pattern-book functions provide the modeler with a collection of shapes. They are not yet fully suited to represent real-world phenomena. To illustrate, consider Figure 7.1 which shows the number of officially confirmed COVID-19 cases in the US in March 2020. 800
The COVID pandemic was widely and appropriately described as “exponential,” so alongside the data Figure 7.1 shows the function \(e^x\).
There’s an obvious mismatch between the data and the function \(e^x\). Does this mean the COVID pattern is not exponential?
A hint comes from the formula \(e^x\). What is \(x\)? Plotted as it is in the graph, \(x\) is the calender day in March. But why shouldn’t \(x\) be the given in hours or minutes or weeks?
If we want the input to \(\exp()\) to be in “hours” instead of “days,” we can multiply \(x\) by 24. If the input is to be in weeks, the multiplier should be \(\frac{1}{7} = 0.1429\). In both cases, the function will be \(e^{kx}\), where \(k\) would be 24 for hours or 0.1429 for weeks. Exploring a bit, we found that \(0.3 \leq k < 0.5\) will produce functions graphs that match the data much better than pattern-book \(e^x\). 810
The multiplier \(k\) in \(e^{kx}\) is called a parameter of the function: a number that we can use to set the scale of the input. To use the exponential function to model COVID, we’ve had to stretch out the red curve in Figure 7.1 by tailoring pattern-book \(x\) as \(k x\). Perhaps it’s a matter of personal choice which size of \(k\) will be best suited to model the data.
My personal choice is \(k=0.30\). My reasoning? The \(k=0.30\) curve roughly parallels the COVID data. The flaw with \(k=0.30\) is that the curve lags the data by several days. But we can fix this by pulling the \(k=0.30\) curve to the left. Mathematically this can be accomplished by subtracting a few days from \(x\) before multiplying by \(k\), that is, using the function \[f(x) \equiv e^{k(x-x_0)}\] where \(x_0\) stands for the shift. (A positive value for \(x_0\) is a shift to the right, a negative value is a shift to the left.)
Figure 7.3 shows (in red) the \(k=0.30\) curve after pulling it 10 days to the left. It’s now a pretty good match to the data.
Note that once we’ve aligned the red curve horizontally, it seems to curve too much. The green curve does much better. It has a much gentler curve, \(k=0.19\) and is pulled about a little more than a month to the left. 820
By parameterizing the exponential function as \(e^{k(x-x_0)}\) and finding suitable values for \(k\) and \(x_0\), we get a good match to the March data. But models can sometimes tell us more. For the green curve in Figure 7.3 the value of \(x_0\) is -32 days. 32 days before March 1 is late January. We know from other sources of information, the outbreak began in late January. It’s remarkable that even though the curve was constructed without any data from January or even February, the data from March, translated through the curve-fitting process, pointed to the start of the outbreak.
7.1 Parallel scales
The graphical format we have been using to display functions of one variable places the input on the horizontal axis and the output on the vertical axis. This is not the only way to draw a function. Consider these everyday objects: a thermometer and a ruler.
Each object presents a read-out of what’s being measured—temperature or length—on two different scales. At the same time, the objects provide a way to convert one scale to another.
A function gives the output for any given input. We represent the input value as a position on a number line—which we call an “axis”—and the output as a position on another output line, almost always drawn perpendicular to one another. But the two number lines can just as well be parallel to one another. To evaluate the function, find the input value on the input scale and read off the corresponding output. The inverse function can be evaluated just as easily: switch the roles of the input and output scales. 830
Taking the traditional (“imperial”10) unit scale as the input and the metric scale as the output, the two functions implemented on the objects are: \[\underbrace{C(F) = \frac{5}{9}(F-32)}_\text{Fahrenheit to Celcius}\ \ \ \text{and}\ \ \ \ \underbrace{\text{cm(inches)} = 2.54 \times (\text{inches}-0}_\text{inches to cm})\] These are very simple, straight-line functions, but they play an important role in modeling.
Each conversion function can be written in the form \(\line(x) \equiv m (x - x_0)\). Of course, if you multiply the \(m\) through both terms in parentheses, you get \(\line(x) = m x - m x_0\) which can be written even more simply as \(mx + b\) by setting \(b\equiv m x_0\). so the conversion function does conform to the straight-line formula we’re used to.
\(m\) and \(x_0\) are the parameters of the straight-line function. In terms of the graph of a straight-line function, \(m\) is the slope and \(x_0\) is the x-intercept respectively.
Often, functions can be parameterized in other ways. For instance, you likely learned the parameterization \(m x + b\), in which \(m\) is (still) the slope of the graph but \(b\) is the y-intercept. (Expanding out \(m(x-x_0)\) and comparing to \(m x + b\), you can see that \(b = m x_0\).)
We can call \(m(x - x_0)\) the “x-intercept parameterization” and \(m x + b\) the "y-intercept parameterization. They are equivalent and equally good ways of parameterizing the straight line. There are still other ways of parameterizing, each style reflecting its own format for specifying the two points that make up a line.
7.2 Scaling the input
To turn a pattern-book function into a basic modeling function all we do is use \(\line()\) to convert the input before applying the pattern-book function. 840
To illustrate the link between basic modeling functions and their pattern-book prototypes, Figure 7.4 shows the model we fit to the COVID-19 data for the cumulative number of confirmed cases for each day in March: \(\text{cases(day)} = e^{0.19(\text{day}- -32)}\)
The function being drawn is simply \(e^x\): a function from the pattern book. The black horizontal scale shows \(x\), the input to the pattern-book function. Where does that value of \(x\) come from? It’s \(0.19(\text{day} - -32)\), where day is the number of the day in March. For instance, on March 20, day\(=10\) and \(0.19*(\text{day}- -32) = 9.88\). You can see that 20 on the blue scale matches 10 on the black scale. The model says that on day 20 (blue scale) the input to the pattern-book function will be 9.88 (black scale). Plugging the input 9.88 into the pattern-book exponential gives \(e^{9.88} = 19536 \approx 20,000\) cases.
The pattern-book function does not give a good model of the COVID case numbers. But if we scale the input before applying the pattern-book function, we are effectively laying a new axis, the blue one in Figure 7.4, that is stretched and shifted from the pattern-book input (blackscale). Using the blue axis lets us read off the number of cases as a function of the day in March.
Input scaling empowers the pattern-book functions to model a huge variety of phenomena. There’s just one exponential function and it always looks exactly the same. But there is a huge variety of ways to draw a blue axis, that is, to scale the input. With input scaling, the pattern-book function is tailored to become one of our basic modeling functions. \[\underbrace{e^x}_\text{pattern-book function}\ \text{versus}\ \underbrace{e^{k(x-x_0)}}_\text{basic modeling function}\] The straight-line function \(\line()\) is being written here as \(k(x-x_0)\) rather than \(m(x-x_0)\). It’s traditional when writing exponential functions to use the letter \(k\) as the multiplier, but you can use whatever name you wish for a parameter. Knowing and using the idiom of mathematical notation will help you read and write mathematics more fluently. 850
The table shows a of the mathematical idioms used in parameterizing the pattern-book functions.
Function | Written form | Parameter 1 | Parameter 2 |
---|---|---|---|
Exponential | \(e^{kt}\) | \(k\) “exponential constant”11 | Not used |
Exponential | \(e^{t/\tau}\) | \(\tau\) “time constant”12 | Not used |
Exponential | \(2^{t/\tau_2}\) | \(\tau_2\) “doubling time”13 | Not used |
Power-law | \([x - x_0]^p\) | \(x_0\) x-intercept | exponent |
Sinusoid | \(\sin\left(\frac{2 \pi}{P} (t-t_0)\right)\) | \(P\) “period” | \(t_0\) “time shift” |
Sinusoid | \(\sin(\omega t + \phi)\) | \(\omega\) “angular frequency” | \(\phi\) “phase shift” |
Sinusoid | \(\sin(2 \pi \omega t + \phi)\) | \(\omega\) “frequency” | \(\phi\) “phase shift” |
Gaussian | dnorm(x, mean, sd) | “mean” (center) | sd “standard deviation” |
Sigmoid | pnorm(x, mean, sd) | “mean” (center) | sd “standard deviation” |
Straight-line | \(mx + b\) | \(m\) “slope” | \(b\) “y-intercept” |
Straight-line | \(m (x-x_0)\) | \(m\) “slope” | \(x_0\) “center” |
7.3 Scale the output
Just as the natural input usually needs to be scaled before it reaches the pattern-book function, so the output from the pattern-book function may need to be scaled before it presents a result suited for interpreting in the real world.
The overall result of input and output scaling is to tailor the pattern-book function so that it is ready to be used in the real world. 860
Name | Pattern-book form | Modeling form |
---|---|---|
exponential | \(e^x\) | \(A e^{kx} + C\) |
sinusoid | \(\sin(x)\) | \(A \sin\left(\frac{2 \pi}{P} (x-x_0)\right) + C\) |
proportional | \(x\) | \(a x + b\) |
The parameter \(C\) is often called the baseline or the offset. Statisticians call it the “intercept,” because it plays the same role as \(b\) in the straight-line function.
When working with sinusoids, parameter \(A\) is called the amplitude.
Of course, you’re already familiar with \(a\) and \(b\): the slope and y-intercept of a straight line.
Our prefered form for the input scaling in the basic modeling functions is \(m(x - x_0)\). Sometimes it can be a little hard to see this form given the conventions for parameterization. For instance, in the basic modeling sinusoid \[\sin\left(\underbrace{\frac{2 \pi}{P}}_m\ \ (x-x_0)\right)\] the multiplier is written \(\frac{2\pi}{P}\) rather than \(m\). 863
In the basic modeling exponential and straight line functions \[A e^{kx} + C \ \ \ \text{and}\ \ \ a x + b\] The \(x_0\) does not appear. Why not?
Suppose we did write the exponential as \[A_2 e^{k(x-x_0)} + B\] This could be simplified algebraically to \[A_2 e^{kx_0} e^{kx} + B\] Although this looks a bit different, note that \(e^{k x_0}\) is simply a number, not a function of \(x\). We can therefore combine it with \(A_2\), giving \(A = A_2 e^{k x_0}\). The \(A\) coefficient in the exponential makes any use of \(x_0\) redundant and unnecessary.
A similar algebra logic applies to the straight-line function \(ax + b\). We don’t need an \(x_0\) there, either.
7.4 Linear combinations
We’ve discussed shifting the baseline of the exponential and sinusoid functions by adding a constant to the basic modeling function, like this:864
\[f(t) \equiv A e^{kt} + C\\ \ \\ g(t) \equiv A \sin\left(\frac{2\pi}{P} t\right) + C\]
We’ve called this output scaling. It’s an example of a much more general and powerful way of contructing modeling functions called linear combinations.
In a linear combination, you start with one or more basic functions. For discussion, let’s call these \(f_1(t)\), \(f_2(t)\), \(f_3(t)\) and so on. In making a linear combination, multiply each of the basic functions by some quantity and add the results together:
\[\text{linear combination of}\ f_1(t)\ \text{and}\ f_2(t): \ \ A_1 f_1(t) + A_2 f_2(t)\] The quantities \(A_1\) and \(A_2\) are called scalars because they scale the functions. (In Chapter ?? you will see that we make a distinction between a scalar, which is a single quantity, and a vector, which is a set of scalars.)
It’s common to take linear combinations of functions with different inputs, for example \[h(x, y, t) \equiv 4 e^{-kt} + 7 y + 2\,\pnorm(x-3) - 19\]
In fields like statistics and economics and other social sciences, as well as clinical medical research, a great number of modeling techniques involve such combinations of functions of various inputs. 866
In engineering and physics, an important class of functions involves a linear combination of many sinusoids of different periods, e.g.
\[\text{signal}(t) \equiv A_1 \sin\left(\frac{2 \pi}{P_1}t\right) + A_2 \sin\left(\frac{2 \pi}{P_2}t\right) + A_3 \sin\left(\frac{2 \pi}{P_3}t\right) + \cdots\]
Linear combination of functions provides a powerful and flexible general-purpose modeling technique in part because many physical systems seem to work this way and in part because the methods for finding the scalars—\(A_1\), \(A_2\), and so on—have an extremely strong theory and fast computer implementations that automatically solve the problem once the modeler has selected the functions she wants to combine. In Block 4, we use the name target problem to refer the problem of finding scalars to match as well as possible a linear combination to data.
An expression like \(A e^{kx} + C\) combines the exponential (obviously!) and a second function that isn’t immediately obvious: the constant function \(\text{constant}(x) \equiv 1\). It might be overkill to re-write the expression as \(A e^{kx} + C\, \text{constant}(x)\) but get in the habit of seeing the constant function as a constant presence in linear combinations!
Polynomials are an important example of linear combinations. Something like \(p(x) \equiv a + b t + c t^2\) is a linear combination of the constant function, the proportional function, and the square function.
7.5 Exercises
Exercise 7.1: MWLCS
Recall that each basic modeling function is constructed from the corresponding pattern-book function by scaling the input.
\[\text{pattern-book function}\ \ \underset{x\rightarrow a(x-x_0)}{\overset{\text{input scaling}}{\Large\Longrightarrow}} \ \ \text{basic modeling function}\]
Figure ?? shows the pattern-book functions with some added annotations. When the function has horizontal or vertical asymptotes, the location is shown by orange arrows. There is also a blue dot placed on the graph of functions with asymptotes. For functions without asymptotes, there are two blue dots. The location of the asymptotes and blue dots mark characteristic features of each function. The positions of the blue dot and asymptotes, or the positions of the two blue dots, are useful for figuring out the values of parameters in basic modeling functions.
For example, the basic modeling reciprocal function is \(g(x) \equiv \frac{1}{m (x-x_0)} + C\). The parameter \(C\) will be the value where the horizontal asymptote crosses the vertical axis. The parameter \(x_0\) will be the value where the vertical asymptote crosses the horizontal axis. As for the parameter \(m\): find the input where the function value is \(C+1\). Let’s call that \(x^\star\). The \(m = 1/(x^\star - x_0)\).
For the sinusoid, the blue dots mark the positive-going zero crossings of the baseline. The horizontal distance between the blue dots is the period parameter, \(P\). The horizontal position of either of the two dots tells the phase offset \(x_0\).
Each of the following plots shows a basic modeling function whose input scaling has the form \(x - x_0\). Your job is to figure out from the graph what is the numerical value of \(x_0\). (Hint: For simplicity, \(x_0\) in the questions will always be an integer.)
In plot (A), what is $$x_0$$? ( ) -2 ( ) -1 ( ) 0 ( ) 1 (x ) 2 [[Right. Look for the input that generates the peak output value.]]
In plot (B), what is $$x_0$$? ( ) -2 (x ) -1 ( ) 0 ( ) 1 ( ) 2 [[The fiducial point is a positive-going zero crossing.]]
In plot (C), what is $$x_0$$? ( ) -2 ( ) -1 ( ) 0 (x ) 1 ( ) 2 [[The vertical asymptote is the clue.]]
In plot (D), what is $$x_0$$? ( ) -2 ( ) -1 ( ) 0 (x ) 1 ( ) 2 [[The input where the output is half way between the two horizontal asymptotes]]
In plot (E), what is $$x_0$$? (x ) -2 ( ) -1 ( ) 0 ( ) 1 ( ) 2 [[Right. The location of the vertical asymtote is the clue.]]
Exercise 7.2: uKCIE
Each of the graphs shows two horizontal scales and one of the basic modeling functions. Which horizontal scale (black or blue) corresponds to the pattern-book function?
For graph (A), which scale corresponds to the pattern-book function? (x ) black ( ) blue ( ) neither ( ) both [[Excellent!]]
For graph (B), which scale corresponds to the pattern-book function? ( ) black (x ) blue ( ) neither ( ) both [[Right. The pattern-book function has an output of 1/2 when the output is zero. That's what the blue scale shows. ]]
For graph (C), which scale corresponds to the pattern-book function? ( ) black (x ) blue ( ) neither ( ) both [[The pattern-book sinusoid has a positive-going zero crossing at $$x=0$$. That's the blue scale.]]
Exercise 7.3: BLECL
Find the straight-line function that will give the value on the black scale for each point \(x\) on the blue scale. The function will take the blue-scale reading as input and produce the black-scale reading as output, that is: \[\text{black}(x) \equiv a (x - x_0)\]
For Graph A, which function maps blue $$x$$ to the value on the black scale? (x ) $$ ext{black}( ext{blue}) \equiv \frac{1}{3} x$$ ( ) $$ ext{black}( ext{blue}) \equiv 3\, x$$ ( ) $$ ext{black}( ext{blue}) \equiv x + 3$$ ( ) $$ ext{black}( ext{blue}) \equiv x - 3$$ [[Nice!]]
For Graph B, which function maps blue $$x$$ to the value on the black scale? (x ) $$ ext{black}( ext{blue}) \equiv -\frac{2}{3}\,x$$ ( ) $$ ext{black}( ext{blue}) \equiv \frac{3}{2} x$$ ( ) $$ ext{black}( ext{blue}) \equiv \frac{2}{3} x$$ ( ) $$ ext{black}( ext{blue}) \equiv -\frac{3}{2}x$$ [[Good.]]
For Graph C, which function maps blue $$x$$ to the value on the black scale? (x ) $$ ext{black}( ext{blue}) \equiv \frac{1}{2}(x - 2)$$ ( ) $$ ext{black}( ext{blue}) \equiv 3\, x$$ ( ) $$ ext{black}( ext{blue}) \equiv 2\,x$$ ( ) $$ ext{black}( ext{blue}) \equiv 2\,(x + 2)$$ [[Good. An interval of length 4 on the blue scale (say, from 2 to 6) becomes an interval of length 2 on the black scale. So you know that blue to black involves dividing by 2.]]
For Graph D, which function maps blue $$x$$ to the value on the black scale? (x ) $$ ext{black}( ext{blue}) \equiv \frac{2}{3} (x + 3)$$ ( ) $$ ext{black}( ext{blue}) \equiv \frac{3}{2} (x - 3)$$ ( ) $$ ext{black}( ext{blue}) \equiv \frac{3}{2} (x+1)$$ ( ) $$ ext{black}( ext{blue}) \equiv rac{3}{2}(x - 2)$$ [[Excellent!]]
Exercise 7.4: ILESX
True or false: $$2^x$$ is a power-law function. ( ) TRUE (x ) FALSE [[Excellent!]]
True or false: $$3/x^2$$ is a power-law function. (x ) TRUE ( ) FALSE [[Good.]]
True or false: $$5\sqrt{x}$$ is a power-law function. (x ) TRUE ( ) FALSE [[Good.]]
The gravitational force, F, between two bodies is inversely proportional to the square of the distance $$d$$ between them. Then ... ( ) $$F = k d^{2}$$ (x ) $$F = kd^{-2}$$ ( ) $$F = k d^{1/2}$$ ( ) $$F = k d^{-1/2}$$ [[Correct.]]
Exercise 7.5: FKLEU
The graph shows a linear combination of two sinusoids, one of period 0.6 and the other of period 2. There is also a baseline shift. That is, the graph shows the function:
\[A_1 \sin\left(\frac{2\pi}{2}t\right) + A_2 \sin\left(\frac{2\pi}{0.6} (t-.3)\right) + A_3\]
What is $$A_3$$? (x ) -4 ( ) -2 ( ) 0 ( ) 2 ( ) 4 [[Excellent!]]
What is $$A_1$$? ( ) 0 ( ) 1 (x ) 2 ( ) 3.5 [[Excellent!]]
What is $$A_2$$? ( ) 0 (x ) 1 ( ) 2 ( ) 3.5 [[Nice!]]