Question

In: Statistics and Probability

1- Write a function f(n,a,b) that generates n random numbers # from Uniform(a,b) distribution and returns...

1- Write a function f(n,a,b) that generates n random numbers
# from Uniform(a,b) distribution and returns their minimum.
# Execute the function with n=100, a=1, b=9.

2- Replicate the function call f(100,1,9) 100 thousand times
# and plot the empirical density of the minimum of 100 indep. Unif(1,9)'s

3-Use the sampling distribution from (b) to find 95% confidence
# interval for the minimum of 100 independent Unif(1,9)'s.

Please solve in R

Solutions

Expert Solution

## R function


Uniform_S=function(nsim)
{
Sam=list()
X=list()
Y=list()

for(i in 1:nsim)
{
Sam[[i]]=runif(n=100, min = 1, max = 9)
X[[i]]=unlist(Sam[[i]])
Y[[i]]=min(X[[i]])
}
return(Y)
}


U=unlist(Uniform_S(nsim=100))

# 2. Replicate the function call f(100,1,9) 100 thousand times
# and plot the empirical density of the minimum of 100 indep

den=density(U)
plot(den)

# 3-Use the sampling distribution from (b) to find 95% confidence
# interval for the minimum of 100 independent Unif(1,9)'s.

n <- length(U)
a <- mean(U)
s <- sd(U)
error <- qnorm(0.975)*s/sqrt(n)
left <- a-error
right <- a+error
left
right

## End the Function

## Run

> Uniform_S=function(nsim)
+ {
+ Sam=list()
+ X=list()
+ Y=list()
+
+ for(i in 1:nsim)
+ {
+ Sam[[i]]=runif(n=100, min = 1, max = 9)
+ X[[i]]=unlist(Sam[[i]])
+ Y[[i]]=min(X[[i]])
+ }
+ return(Y)
+ }
>
>
> U=unlist(Uniform_S(nsim=100))
>
> # 2. Replicate the function call f(100,1,9) 100 thousand times
> # and plot the empirical density of the minimum of 100 indep
>
> den=density(U)
> plot(den)
>
> # 3-Use the sampling distribution from (b) to find 95% confidence
> # interval for the minimum of 100 independent Unif(1,9)'s.
>
>
>
> n <- length(U)
> a <- mean(U)
> s <- sd(U)
> error <- qnorm(0.975)*s/sqrt(n)
> left <- a-error
> right <- a+error
> left
[1] 1.056143
> right
[1] 1.078315
>

## Density plot


Related Solutions

Consider a random sample of size n from a distribution with function F (X) = 1-...
Consider a random sample of size n from a distribution with function F (X) = 1- x-2 if x > 1 and zero elsewhere. Determine if each of the following sequences has distribution limit; if so, give the limit distribution. a)x1:n b)xn:n c)n-1/2 xn:n
Write a function called alter_sum(n)that returns the alternating sum of all the numbers from 1 to...
Write a function called alter_sum(n)that returns the alternating sum of all the numbers from 1 to n so that the first number is added, the second number is subtracted, the third number added, the fourth subtracted, and so on: 1-2+3-4+5-6+7… until you reach n. If n is 0 or less then return 0.
Suppose you have access to a random number generator Rng() that generates uniform random numbers in...
Suppose you have access to a random number generator Rng() that generates uniform random numbers in {0, 1, . . . , n − 1}. Design a function uses Rng() generate a uniform random number in {0, 1, . . . , m − 1}, where m ≤ n
A random number generator returns random floats between 0 and 1, according to a uniform distribution....
A random number generator returns random floats between 0 and 1, according to a uniform distribution. say you let the random number generator draw 100 numbers, the sample mean will be... A.impossible to determine, because the data aren't drawn from a normal distribution. B.normally distributed, with mean 0.5 and standard deviation 0.2887. C.uniformely distributed, between 0 and 1. D.normally distributed, with mean 0.5 and standard deviation 0.02887.
In Excel, the RAND function generates random numbers between 0 and 1 compute the expectation and...
In Excel, the RAND function generates random numbers between 0 and 1 compute the expectation and Standard deviation. Hints a = 0 , b = 1 P(x1<= X <= x2) = F(x2) - F(x1)
Write a C++ program that randomly generates N integer numbers (such that N is entered by...
Write a C++ program that randomly generates N integer numbers (such that N is entered by the user) and then stores them to a text file (myNumbers.txt) sorted in increasing (non-decreasing) order. Again, please notice that the size of the data (N) is known during the run time, not the compile-time (needs to be entered by the user after running the program).
A random sample of size n from a distribution by f(x) = 2x and F(x) =...
A random sample of size n from a distribution by f(x) = 2x and F(x) = x^2 ; 0 < x < 1. Let R = X(n) − X(1) be the range of the sample. Give a general form of the density function of R
In Assembly Language Write a program that generates 10 random numbers (0~99). Save the numbers into...
In Assembly Language Write a program that generates 10 random numbers (0~99). Save the numbers into arrayInt and calculate the sum. .data arrayInt Byte 10 DUP(?) Displays the array and the sum as follows: The random numbers are: xx xx xx xx xx xx …. The sum is   xxxx
Suppose that Y1 ,Y2 ,...,Yn is a random sample from distribution Uniform[0,2]. Let Y(n) and Y(1)...
Suppose that Y1 ,Y2 ,...,Yn is a random sample from distribution Uniform[0,2]. Let Y(n) and Y(1) be the order statistics. (a) Find E(Y(1)) (b) Find the density of (Y(n) − 1)2 (c) Find the density of Y(n) − Y (1)
Write a function that will accept a list of numbers and an integer (n). The function...
Write a function that will accept a list of numbers and an integer (n). The function should return a list containing every nth item from the input list, always starting with the first item in the list. The original list should not be modified. For example, if the function is passed the list [8, 3, 19, 26, 32, 12, 3, 7, 21, 16] and the integer 3, it will return the list [8, 26, 3, 16] If the function is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT