Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Use the test statistic of mean) The middle-square method (feel free to click on this link and read the wiki page) is a very old

(Use the test statistic of mean)

The middle-square method (feel free to click on this link and read the wiki page) is a very old and very crude pseudorandom generator function invented by John von Neumann in 1949. Despite its many flaws, it was much faster than other more rigorous methods at the time, so was useful in certain contexts where "perfect" randomness was not necessary.

Suppose we start with the 6-digit seed number 455455. This is our first "random" number. Next, we square this number 455455=207,439,257,025 and we take out the middle 6 digits 439257 and this becomes out next "random" number. This process is repeated as many times as needed to get a sequence of "random" numbers.

Due to the primitive nature of this method, the sequence generated actually fails many common tests of true randomness and is therefore NOT a good way of generating random numbers. Below, we have generated a sequence of 200 numbers using this method starting from the initial seed value of 455455. Conduct a Monte Carlo test to show there is indeed strong evidence to indicate this method is NOT a good pseudorandom algorithm.

Use =0.05=0.05. You are NOT allowed to use a different .

middle_square = function(x) as.integer(substr(as.character(x^2),4,9)) N = 200 mc.mid = c(455455,rep(NA,N-1)) for(i in 1:(N-1)) mc.mid[i+1] = middle_square(mc.mid[i]) mc.midmiddle_square = function(x) as.integer(substr(as.character(x^2),4,9)) N = 200 mc.mid = c(455455,rep(NA,N-1)) for(i in 1:(N-1)) mc.mid[i+1] = middle_square(mc.mid[i]) mc.mid

a.Write down a null and alternative hypothesis for this question. Use specific, technical, statistical language here (just saying "random" will NOT be sufficient, what are you specific assuming under the null?).

REPLACE THIS WITH YOUR RESPONSE

b.Construct a statistic, and simulate its distribution under the null. Your result should be a single vector of M numbers, where M is your number of MC iterations, and each number is the result of running your summary statistic on a null-generated sample of size 200.

# insert code here

c.Show a histogram with the null distribution and a line showing what statistic you observed in your real data set. You are welcome to use either tidyverse or base R graphics, just make sure you add a title and axes labels.

  • If you want to make a really quick base R plot, remember you can use hist(x) to get a histogram of a vector x and abline(v=___) to add a vertical line to the plot at x=___x=___.
# insert code here

d.Compute the p-value of your test.

# insert code here

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mathematics for Economics and Business

Authors: Ian Jacques

9th edition

129219166X, 9781292191706 , 978-1292191669

More Books

Students also viewed these Mathematics questions

Question

Explain Computer Network Types.

Answered: 1 week ago