首页 >
> 详细

MATH4/68091 Statistical Computing Coursework 1 (Oct 2019)

To be submitted by 7.00 pm on Sunday 27 October 2019

This coursework is worth 40 marks all together.

Late Submission of Work: Any student’s work that is submitted after the given deadline will be

classed as late, unless an extension has already been agreed via mitigating circumstances or a DASS

extension. The following rules for the application of penalties for late submission are quoted from the

University guidance on late submission document, version 1.3 (dated July 2019).

”Any work submitted at any time within the first 24 hours following the published submission deadline

will receive a penalty of 10% of the maximum amount of marks available. Any work submitted at any

time between 24 hours and up to 48 hours late will receive a deduction of 20% of the marks available, and

so on, at the rate of an additional 10% of available marks deducted per 24 hours, until the assignment is

submitted or no marks remain.”

Your submitted solutions should all be in one document. You are strongly advised to produce this

document using LaTex, but if you do feel that you have to use Word, then this will not be penalised.

For each part of the three questions you should provide explanations as to how you completed what is

required, show your working and also comment on computational results, where applicable.

When you include a plot be sure to give it a title and label the axes correctly.

When you have written or used R code to answer any of the parts, then you should list this R code after

the particular written answer to which it applies. This may be the R code for a function you have written

and/or code you have used to produce numerical results and plots.

If you use Latex to produce your report, you can include R code and output from R using the verbatim

environment. ie. type

\begin{verbatim}

copy and paste lines of text from R here

\end{verbatim}

Your file should be submitted through the module site on Blackboard to the Turnitin assessment entitled

”SC Coursework 1” by the above time and date. The work will be marked anonymously on Blackboard so

please ensure that your filename is clear but that it does not contain your name and student id number.

Similarly, do not include your name and id number in the document itself.

Turnitin will generate a similarity report for your submitted document and indicate matches to other

sources, including billions of internet documents (both live and archived), a subscription repository of

periodicals, journals and publications, as well as submissions from other students . Please ensure that the

document you upload represents your own work and is written in your own words. The Turnitin report

will be available for you to see shortly after the due date.

This coursework should hopefully help to reinforce some of the methodology you have been studying, as

well as the skills in R you have been developing in the module so far.

1. A sequence of n pseudo-randomized observations on the interval [0, 1] can be obtained using the

linear congruential generator which works as follows:

yi = (ayi−1 + c) (mod m), ui =yim − 1, i = 1, . . . , n

for suitable choices of the modulus m, the multiplier a, the increment c and the seed 0 ≤ y0 < m.

(See Section 1.8 (Week 1) of the course notes.)

(i) Write an R function with the five arguments n, m, a, c and initial value y0 to generate a sequence

of n random observations on [0, 1] which are output from the function in a single vector of

length n.

Run your function with the parameter values m = 231 − 1, a = 48271, c = 0 and y0 = 7948 to

generate a sample of size n = 1000.

Please list the first six values u1, . . . , u6 that you simulate, but do not print out all 1000 values

in your report!

[3 marks]

(ii) Manually produce (ie. write the code to do it yourself, rather than relying on any generic R

functions to directly compute the desired results) a probability-probability (P-P) plot (explained

below) of your simulated data (u1, . . . , u1000) to obtain a graphical impression of

whether they can be regarded as being a random sample from a U(0, 1) distribution.

[The general procedure for producing a P-P plot for a sample of data to check whether it

looks plausible that it may be drawn from a particular hypothesised distribution is as follows:

If we have a random sample which is denoted by x1, . . . , xn then the empirical distribution

function of the data is given by

where the indicator function IA is defined to be equal to 1 if the event A occurs and equal to

0 otherwise. Hence,

Fˆn(x) = number of sample observations ≤ xn

Let the hypothesised distribution from which the sample is assumed to be drawn from be

denoted by F0(x).

To obtain the probability plot for your data, construct a scatterplot of the pairs

(Fˆn(x1), F0(x1)), . . . ,(Fˆn(xn), F0(xn))

and look for how well they agree. The reasoning is that we are comparing the nonparametric

Fˆn(x), which can be shown to be an unbiased estimator of the true distribution function of

the random sample, with the hypothesised parametric distribution function F(x). If our hypothesis is correct, then the two should match well when they are evaluated at each of the

sample values.]

Can you graphically enhance your probability plot by providing an aid for subjectively judging

whether the hypothesis of a U(0, 1) distribution is plausible?

Calculate an appropriate summary statistic to quantify the strength of agreement in some

sense between Fˆ

n(x) and F0(x). Give your view as to the suitability of your chosen statistic

and comment on its numerical value.

[Nb. You do not have to write your own code here to manually calculate your choice of

summary statistic; you may use a function already available in R.]

[7 marks][10 marks for Q1]

2. It is proposed to use the inverse cdf method to simulate random data from the standard double

exponential distribution with pdf f(x) = 1

(i) Find the cdf of the standard double exponential distribution.

[2 marks]

(ii) Describe in detail the steps of the inverse cdf method to obtain a random sample of size n

from f(x).

[3 marks]

(iii) Write a function to implement the steps you have described in part (ii) which will output a

random sample of size n from f(x).

Run your function written for part (iii) to generate a random sample of size n = 5000 from

f(x). (Note that you can use the R function runif to generate the required random Uniform

data here.)

[4 marks]

(iv) Construct a histogram of the data generated in part(ii), superimpose the pdf f(x) and comment

on the goodness-of-fit.

[3 marks][12 marks for Q2]

3. Suppose now that we want to simulate random data from the standard Normal distribution whose

pdf is given by

It is proposed to use a rejection sampling algorithm where the proposal distribution is the standard

double exponential distribution from Q2 with pdf

(i) Show that the value of the constant K such that

(ii) Produce on the same plot graphs of the functions f(x) and Kg(x) using the value of K

determined in part(i).

[2 marks]

(iii) Describe the steps of the rejection sampling algorithm which can be used to sample from the

standard Normal f(x) here with the proposed g(x).

[4 marks]

(iv) Theoretically, how efficient should your rejection sampling algorithm described in part (iii)

be?[1 mark]

(v) Write a function which will generate a random sample of size n from f(x) using your algorithm

from part (iii). Your function should include a calculation of an empirical estimate of its

efficiency.

(Note that you should use the R function you have written in Q2(iii) to generate random

observations from the standard double exponential distribution. If this does not appear to be

working correctly for you, then as an alternative, you can generate random standard double

exponential data using the rexp R function, together with random U(0, 1) (using R function

runif) observations in order to decide whether sampled Ex(1) values should be positive or

negative. A sampled Ex(1) observation will be assigned either a positive or negative sign ,

each with probability 0.5, to produce a random observation from g(x) here.)

Run your algorithm to generate a random sample of size n = 5000 from the standard Normal

distribution f(x).[5 marks]

(vi) Choose a single type of plot yourself to enable you to graphically explore whether your random

data is consistent with being sampled from a standard Normal distribution.

Note that, as along as your plot is appropriate for the purpose, then one choice will not be

regarded as being more correct than another. The important things are being able to explain

and interpret the plot you produce correctly.

[3 marks][18 marks for Q3]

联系我们

- QQ：99515681
- 邮箱：99515681@qq.com
- 工作时间：8:00-23:00
- 微信：codinghelp

- 4Cosc001w作业代做、Python程序语言作业调试、Python课程作 2019-11-20
- 代写csc 230作业、代做ascii留学生作业、Python，Java程序 2019-11-20
- Cmpt 361作业代写、代做system留学生作业、Java，C++编程语 2019-11-20
- 代做cs5783留学生作业、代写machine Learning作业、代写c 2019-11-20
- B365留学生作业代做、代写iris Data作业、代做r程序语言作业、代写 2019-11-20
- Inft 3033作业代做、代写c/C++编程语言作业、代做c++课程设计作 2019-11-20
- Cs610-101作业代写、Programming课程作业代做、C/C++, 2019-11-20
- Econ 385作业代做、R程序设计作业代写、代做r课程设计作业、Ols留学 2019-11-20
- Engg1330作业代做、代写programming作业、代写java编程语 2019-11-20
- 代写csv File作业、Dataset留学生作业代做、代写java，C++ 2019-11-20
- Web Scraping作业代做、代写media Website作业、Web 2019-11-19
- 代写module留学生作业、代写java课程设计作业、Java程序语言作业调 2019-11-19
- Cs 344留学生作业代做、C++编程作业调试、C++课程设计作业代写、代做 2019-11-19
- 代做econ 493作业、Data留学生作业代写、代做r实验作业、R编程设计 2019-11-19
- 代写cmpt 361作业、代做system留学生作业、代做python，C+ 2019-11-19
- Isa 414作业代写、R程序语言作业调试、R课程设计作业代做、代写canv 2019-11-19
- Mat 4378作业代做、代写categorical Data作业、代做r编 2019-11-19
- Stat 429作业代做、代写mathematics课程作业、代做r编程语言 2019-11-18
- 代做431 Quiz 2作业、R编程设计作业调试、R语言作业代写、代做dat 2019-11-18
- 代写mt5761留学生作业、代做statistical Modelling作 2019-11-18