STATS782-统计代写-Assignment 3
时间:2023-05-14
Department of Statistics
STATS 782 Statistical Computing
Assignment 3 (2023; Semester 1)
Total: 65 marks Due: 10:00 NZDT, May 15, 2023
Notes:
(i) Please do not use any external R packages for this assignment.
(ii) When mimicking the plots given to you, we reserve the right to decide what is close enough.
Also,
– Please include basic information behind how you constructed your plot by a short descrip-
tion in English.
– The dimension of your plot should be very similar or the same as the original. Create
your plot in .pdf and upload it to Canvas. The originals will be made available to you.
– Of course, try to match the colours reasonably closely without spending hours on it.
– As always, marks will be awarded for correctness, simplicity, readability, and the ability
to change certain major features easily, etc.
(iii) Please see Canvas for any other instructions.
1. [15 marks] Consider the equation
y2 (a2 − x2) =
[
x2 + 2ay − a2
]2
(1)
on the plane, where a = (1 + d)/3 and d is the last digit of your UPI (so that a is positive and
no more than 4).
(a) Use R to plot the equation with the x- and y-axes on the same scale. Note: it can be
done in a reasonably basic way. Hint: don’t use contour() and the answer reminds me
of something you might see in the sky. Because of symmetry, only consider what is above
the horizontal axis. [10 marks]
(b) Compute the area numerically using integrate(). It should be accurate to at least five
decimal places. [5 marks]
2. [10 marks] Consider Fig. 1, which was put on https://timesofindia.indiatimes.com as an
optical illusion/brain teaser to help ward off dementia and Alzheimer’s disease. The challenge
is to find the word ‘LARGE’ in the image within 10 seconds.
Use R to reproduce the figure closely. Further notes:
ˆ Feed the last three digits of your UPI into set.seed() to position your word ‘LARGE’.
Its position should be uniformly distributed over the ‘grid’, and there is to be only one
‘LARGE’. That is, your position will probably not match the original.
ˆ You should write a function having at least two arguments, e.g., drawLARGE(width = 8,
height = 11) so that it can easily be changed to a 12 × 9 grid, say, for another Indian
newspaper. Your function should invisibly return the location of your ‘LARGE’ and the
grid size.
ˆ Fonts are very OS-specific but there are sometimes good options, e.g., on macOS you can
try "Arial Narrow" or even better "Futura Condensed Medium" which gets a lot closer.
My solution is so different so that you don’t have to match the font if that’s too difficult.
Figure 1: Scaled original from the internet.
2
3. [10 marks] Consider Fig. 2 which is based on a picture from the internet. Viewers are
supposed to find the (one) star that differs from the others within 16 seconds.
Use R to reproduce the figure closely. Further notes:
ˆ The position of your aberrant star should be uniformly distributed over the ‘grid’ based
on the last three digits of your UPI—input it into set.seed().
ˆ You should write a function having at least two arguments, e.g., drawstars(width = 7,
height = 5) so that it can easily be changed. Your function should invisibly return the
location of your aberrant star and the grid size.
Figure 2: A (scaled) grid of stars. Using my coordinate system, the answer is in position (1, 2).
4. [10 marks] Consider Fig. 3 which is an optical illusion because the horizontal bar is in
fact just one colour—even though it appears to progress from light gray to dark gray.
Use R to reproduce the figure closely. Hint: use pdf(..., height = 4, width = 6)
Figure 3: Scaled original from the internet.
3
5. [20 marks] Consider Fig. 4 which was downloaded from
https://climate.nasa.gov/vital-signs/global-temperature
(a) Read the data into R by first downloading the text file. Obtain a summary() of your data
frame and comment. [4 marks]
(b) Plot the data to create a .pdf file that is very similar to Fig. 4. However, [11 marks]
– don’t spend hours on it to make it exactly the same;
– don’t plot the third Lowess column of data—you are to use lowess() to do it yourself!
Hint: use pdf(..., height = 5.2, width = 8)
(c) Continuing from (b) and without doing too much extra work, add some improvements to
the plot. Justify your improvements. Produce a new plot. [5 marks]
Figure 4: Original plot (scaled) in .png given on the NASA website.
Version 2
essay、essay代写