Chap 10 Exercises

\[ \newcommand{\dnorm}{\text{dnorm}} \newcommand{\pnorm}{\text{pnorm}} \newcommand{\recip}{\text{recip}} \]

Exercise 1 Use the function named \(\text{twins}(x,y)\) to practice making contour plots.

Active R chunk 1
  1. The domain of the plot should be large enough to show a mountain next to a deep hole. Which of these domains will do the job?

bounds(x=c(-5, 5), y=c(-5, 5)

bounds(x=c(1, 5), y=c(1, 5)

bounds(x=c(1,1), y=c(-1,1)))

bounds(x=c(5,10), y=c(0,10)))

question id: drl-1

Using Active R chunk lst-KWLCie-2 draw a slice through the function along the line \(y=0\). Use the same \(x\)-domainas in the correct answer to the previous question.

In the slice_plot() command below, you will need to replace __tilde-expression___ and __domain__ with the correct syntax.

Active R chunk 2

Which of these expressions will accomplish the task?

slice_plot(twins(x, y=0) ~ x, bounds(x=c(-5,5)))

slice_plot(twins(x) ~ x, bounds(y=c(-5, 5)))

slice_plot(twins(x, y=0) ~ x, bounds(x=c(-5, 5), y=c(-5, 5)))

slice_plot(twins(x, y=0) ~ x + y, bounds(x=c(-5, 5), y=c(-5, 5)))

question id: drl-2

Exercise 2 Many printed tables are meant to be used as functions, as in Figure fig-heat-index-1; you plug in the input values and read off the output.

Figure 1
  1. What are the inputs to the heat-index function

temperature and relative humidity

temperature and wind speed

temperature, latitude, and longitude

question id: dd-01-1

Figure fig-heat-index-1 shows three different functions:

  1. The heat index in \(^\circ\) F.

  2. The heat index in \(^\circ\) C.

  3. A caution warning level.

  4. For inputs of 70% relative humidity and \(88^{\circ}\) F, what are the outputs of the three functions?

\(100^{\circ}\) F, \(38^\circ\) C, and “extreme caution”.

\(100^\circ\) F, \(38^\circ\) C, and “danger”.

\(100^\circ\) F, \(33^\circ\) C, and “extreme caution”.

question id: dd-01-2

  1. Holding the relative humidity at 70%, how much would the ambient temperature have to increase (from \(88^\circ\) F) to change the caution-level output to “dangerous”?

Increase by \(2^\circ\) F

Increase by \(6^\circ\) F

Increase relative humidity to 80%.

question id: dd-01-3

  1. From a starting point of \(88^\circ\) F and 70% humidity, what is the slope of the increase in heat index when moving to 80% humidity.

\(6^\circ\) F per 10 percentage points humidity

\(6^\circ\) F

\(6^\circ\) F per 80% humidity.

question id: dd-01-r

  1. What is the heat-index output when the inputs are 52% relative humidity and \(91^\circ\) F? Choose the best answer.

\(98.4^\circ\) F

\(101^\circ\) F

The table does not say.

question id: dd-01-5

  1. True or false: The caution-level output could have been presented as a function of just one input, rather than needing both temperature and humidity.
TRUE       FALSE      

question id: dd-01-6

Exercise 3 The model \[\hspace{-2in}\text{price}(\text{livingArea}, \text{bedrooms}, \text{bathrooms}) \equiv\\\] \[ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 21000 + 105\,\text{livingArea} - 13000\, \text{bedrooms} + 26000\, \text{bathrooms}\] is described in the text as being a linear combination of functions. Which of these best describe those functions?

There are no functions, just inputs.

Three identity functions, each of which takes a different input.

Four identity functions, each of which takes a different input.

Three identity functions, each of which takes a different input, and a fourth function, namely the constant function \(\text{const}(x) \equiv 1\)

question id: identity-constant

Exercise 4 Even if you don’t yet have a theoretical understanding of how to construct functions with multiple inputs from data, you can R/mosaic operations for doing so. A key function is fitModel(), which like makeFun(), constructs a function. And, like makeFun(), you need to use a tilde expression to specify the model formula. But, unlike makeFun(), you can leave it to the computer to find the parameters that will make the function align with data.

To illustrate, we can construct a housing-price model from the SaratogaHouses data:

Note that in applying the price() function to inputs, we are using the names of the inputs explicitly. To write the command price(2000,3,2) risks mixing up which input is which.

Use the function in the ordinary way. For instance, here is what the model has to say about the anticipated sales price of a house with 2000 square feet of living area, three bedrooms, and two bathrooms.

For technical reasons, the functions created by fitModel() have a lot of computer-programming jargon in them, as you can see by constructing the model itself and then looking at the function. But you will also see the values of the parameters found by fitModel().

Class activity

Exercise 5 Auckland, New Zealand is in a field of dormant volcanos. The highest, at 193 meters above sea level, is Maungawhau. Formerly, tourists could drive to the peak and look down into the crater, as seen in the picture.

Figure 2: Panoramic photo of the crater of Maungawhau, near Auckland, New Zealand. Source

The initial creator of R, Ross Ihaka, teaches at the University of Auckland. His digitization of a topographic map is easily plotted, as here:

Figure 3: A combination surface and contour plot of the topography of Maungawhau.

The z-axis is height and is in meters. The x- and y-axes are latitude and longitude, measured in 10-meter units from a reference point. (So, \(x=10\) is 100 meters from \(x=20\).)

Get used to the presentation of the surface plot and how to rotate it and zoom in. To see the crater more clearly, you can rotate the surface plot to look straight downwards, effectively presenting you with a color-coded contour plot. Moving the cursor over the surface will display the \(x\) and \(y\) coordinates, as well as the \(z\)-value at that coordinate point.

  1. What is the \((x, y)\) location of the low-point of the crater? (Choose the closest answer.)
\((x=34, y=29)\)       \((x=31, y=25)\)       \((x=25, y=34)\)       \((x=29, y=34)\)      

question id: crater-location

  1. What color is used to designate the lowest elevations?
dark blue       green       yellow      

question id: crater-color

If you were to climb up Maungawhau, at some point you would be at the same elevation as the low-point of the crater, even though you are outside the crater. Think of the contour that corresponds to that elevation. Let’s call it the “half-way” contour since it is roughly half-way up the volcano.

  1. What is the shape of the “half-way” contour?
a line segment       a crescent       a closed curve       a cross      

question id: crater-contour

Imagine that you are filling up the crater with water. At some point, the water rises to a level where it will spill over the lip of the crater.

  1. What is the elevation at which the water will start to spill over the crater lip? (Pick the closest answer.)
169 meters       172 meters       175 meters       178 meters      

question id: crater-lip

  1. Explain in terms of the shapes of contours how you can identify the elevation at which the water would spill over the rim.

question id: crater-spillover

No answers yet collected