Question

Use linear congruential generator with seed value 31, a = 11, c = 17, m =...

Use linear congruential generator with seed value 31, a = 11, c = 17, m = 100 and inverse transform technique to generate:

  1. 10 continuous uniform random variates on interval [1; 10];                                             [5]
  2. 10 exponential random variates with parameter λ = 3.                                                     [2]
  3. It is suspected that the generated random numbers (Ri) are autocorrelated, since an observer notices that every 4th number starting (but not counting) from the 1st number (i.e. i = 1) is larger than the numbers preceding or following it. Test the hypothesis of independence of random numbers at 2-sided level of significance α = 0.05 using autocorrelation.                                                                                                        [10]
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#uniform u(1,10)
a=11;c=17;m=100;
n=10;seedx=31;
x=vector("numeric")
for (i in 1:n) {
x[i]=(a*seedx+c)%%m
seedx=x[i]
  
}
z=x/sum(x)
u=round(z*9,0)+1
u # uniform 1 to 10

#Exponential with lamda=3
exp.no<- function(n,lamda) {
if(lamda<=0 && n<=0)
{
print("wrong")
}
else
{
u=runif(n)
x=NULL
x1=NULL
for (i in 1:n) {
x=-lamda*log(1-u[i])
x1=append(x1,x,after = length(x))
}
}
return(x1)
}
a=exp.no(10,3) # exp(n=10,lamda=3)
#install.packages("randtests)
library(randtests)
randtests::runs.test(a,alternative = "two.sided")

Add a comment
Know the answer?
Add Answer to:
Use linear congruential generator with seed value 31, a = 11, c = 17, m =...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT