None Reading_04

Challenge

In this notebook, your challenge is to use a lookup table model to predict what happens beyond the boundaries of the data you collected to produce that model. As a reminder, the system we're trying to understand is still this one:

While the "lookup table" approach we used in the previous notebook's challenge may have been reasonably effective at predicting subsequent system behavior, it can only tell us about behavior that falls within the time and output ranges described by the table. If a subsequent experiment falls outside the bounds of what our lookup table describes, we are once again out of tools for model construction.

consider the following 'lookup table' model, which was made from the 'test run' data I collected for you in the previous assignment (I chose this so we have a consistent lookup table model to look at. Each of you has your own for the last assignment!). Using linear interpolation, we could use this model to predict the behavior of the system represented by the model on a subsequent test, but only as long as the behavior we wish to predict represents height values between .074m and .057m.

In [2]:
data = load('reading3data.txt');
t = data(:,1);
y = data(:,2);
y(1)
y(end)
plot(t,y,'ks-')
xlabel('Time (s)')
ylabel('Water Height (m)')
ans =  0.074374
ans =  0.056715

But what if what we need is to know what happens after the system decreases past 0.057m? We will have to use what we know about what the system did in the range of output values that make up our lookup table to infer what will happen outside of those boundaries. The simplest tool we can use for this task is called linear exptrapolation.

Linear Extrapolation

Extrapolation is the act of estimating a variable's value beyond the variable's original observation range. The simplest way to do this is by assuming that after a system's behavior leaves the boundaries of the original lookup table, it continues to progress as a linear function with the equation of the line defined by the last two points in the table.

In linear interpolation, we used the slope of the line in between two points in our lookup table to infer the value of a dependent variable in between those two points. In linear extrapolation, we use the slope between two points on our plot to infer what lies beyond them. This is shown graphically below.

image-2.png

predicting the value of $y$ at time $t_p$ using linear extrapolation means using the values of $y(t_{k-1})$ (the second to last point in the dataset) and $y(t_k)$ (the last point in the dataset) to write the equation of a line between the two points. Then, following that line out to time $t_p$ gives us an estimate for $y(t_p)$. Mathematically, we can write this in point-slope form as:

$$ y(t_p) = y_p = m(t_p-t_k) + y(t_k)$$

Where the slope $m$ is given by: $$ m = \frac{y_k-y_{k-1}}{t_k-t_{k-1}}$$

Putting these two equations together yields our total equation for extrapolation as:

$$y(t_p) = y_p = \frac{y_k-y_{k-1}}{t_k-t_{k-1}}(t_p-t_k)+y(t_k)$$

This equation looks eerily similar to the interpolation equation, and that's because it is. The main difference is subtle but important: in interpolation, we are finding an unknown value between two known points. In extrapolation, we are finding an unknown value beyond any known points.

Assignment

Using the dataset above from reading 3 as a lookup table, and imagining that you ran a new experiment that began with a water height of $0.074m$, predict the value of the water height at the following times in seconds:

tpred = [ 80 90 100 110 120]

Note that later, you ran a second experiment that was 100 seconds long. The video of this second experiment is shown below. Record data from this experiment to use for model evaluation. You may only use this dataset for model evaluation. Do not use it for prediction.

Deliverables: Model Construction

In the code cell below, use extrapolation to make the five predictions.

In [4]:
% YOUR CODE HERE
error('No Answer Given!')
error: No Answer Given!

Deliverables: Model Evaluation

In the code cell below, plot these predictions on top of the "true" values of water height $y$ at tp = [80 90 100 110 120]; seconds from the dataset you collected on video. you may want to use colors and markers to plot your predictions so it is easy to differentiate them from the original dataset. Adding a legend so that a reader knows what is data and what is a prediction will also be helpful.

In [5]:
% YOUR CODE HERE
error('No Answer Given!')
error: No Answer Given!

In the markdown cell below, comment briefly on how well extrapolation works as a model construction tool for this problem. Where, and how, if anywhere, is it useful? Where and how, if anywhere, does it produce poor predictions? Why do you think this is the case?

YOUR ANSWER HERE