Question

In: Computer Science

Write a function that inputs the, n, the number of random trials for a standard normal...

  1. Write a function that inputs the, n, the number of random trials for a standard normal distribution and then generates an array of n random observations (ie generate a random sample of n observations from a N(0,1) distribution. Then have the function perform a simple t-test on the sample, testing the null hypothesis that is mean 0. Have the function return two things: the results of the ttest and another variable that is set to the string= “reject” if the p-value is less than .1, and “not” if otherwise. Then call the function 20 times for n=25 and generate a new list that appends “reject” or “not reject” for each test. Comment on whether there is any rejection of the null or not and why this might be.

USING PYTHON ONLY

Solutions

Expert Solution

solution:

given data:

Python code:

SOURCE CODE:

import numpy as np
def fun():
arr=np.random.randn(1);
if(arr<0.1):
return arr,"reject";
else:
return arr,"not reject";
L=[];
for i in range(25):
res=fun();
L.append(res[1]);
print(L);

SOURCE CODE:

import numpy as np
def fun():
arr=np.random.randn(1);
if(arr<0.1):
return arr,"reject";
else:
return arr,"not reject";
L=[];
for i in range(25):
res=fun();
L.append(res[1]);
print(L);

OUTPUT:

please give me thumb up


Related Solutions

Write a function called tokenizeTelNum that inputs a telephone number as a string in the form...
Write a function called tokenizeTelNum that inputs a telephone number as a string in the form (555) 555-5555. The function should use the function strok to extract the area code as a token, the first three digits of the phone number as a token and the last four digits of the phone number as a token. The seven digits of the phone number should be concatenated into one string. The function should convert the area code string to int and...
1) a) Write a MATLAB function called Area1 having two inputs, r and N, and an...
1) a) Write a MATLAB function called Area1 having two inputs, r and N, and an output, A1. The output A1 should be the area under a curve, f(x), for x starting at x_start and ending at x_end. The input r should be a vector (array) having x_start and x_end as its two elements. The input N should be an integer equal to the number of equallength sub-intervals in which the interval from x_start to x_end should be divided. Here,...
4. If Z is a standard normal random variable, that is Z ∼ N(0, 1), (a)...
4. If Z is a standard normal random variable, that is Z ∼ N(0, 1), (a) what is P(Z 2 < 1)? (b) Find a number c such that P(Z < c) = 0.75 (c) Find a number d such that P(Z > d) = 0.83 (d) Find a number b such that P(−b < Z < b) = 0.95
Write a function such that given a number N, display the N*N multiplication matrix from 1...
Write a function such that given a number N, display the N*N multiplication matrix from 1 to N. Then, write a C++ program such that, it prints the multiplication matrices of numbers 1,4,7, and 10 using a loop concept. Check the sample output below, to see how the program should work. Make sure to have your output exactly the same as the below output.
Let Z be a standard Normal random variable. Define Za2 to be the number y such...
Let Z be a standard Normal random variable. Define Za2 to be the number y such that P( Z > y ) = a (this is the standard definition). What is P( Z < Zo.2 )? (i.e. what is the probability that a standard Normal variable takes a value below Zo.2 ?)
Let N be a binomial random variable with n = 2 trials and success probability p...
Let N be a binomial random variable with n = 2 trials and success probability p = 0.5. Let X and Y be uniform random variables on [0, 1] and that X, Y, N are mutually independent. Find the probability density function for Z = NXY . Hint: Find P(Z ≤ z) for z ∈ [0, 1] by conditioning on the value of N ∈ {0, 1, 2}.
In a program, write a function that accepts two arguments: a list, and a number n....
In a program, write a function that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all of the numbers in the list that are greater than the number n. The program should ask for a list of numbers from the user as well as a value (a, b, c)--> inputs from user. After that, each number in that list should be compared to that value (a or b or...
Write a function in Matlab that takes as input the number n and a symmetric tridiagonal...
Write a function in Matlab that takes as input the number n and a symmetric tridiagonal matrix given as two vectors: n×1 vector v representing the main diagonal and (n−1)×1 vector w representing the upper diagonal. Have this function output the Cholesky factor of the matrix as a vector for the main diagonal and a vector for the upper diagonal and output the number of flops and, separately, the number of square roots used as well. Use only basic programming....
Binomial distributions are approximately normal when the number of trials is large, and the probaility of...
Binomial distributions are approximately normal when the number of trials is large, and the probaility of success is not near zero or one. A player flips an unbiased coin 1,296 times. a. What is the probability of the coin landing on heads between 612 and 684 times?
Determine the indicated probability for a binomial experiment with the given number of trials n and...
Determine the indicated probability for a binomial experiment with the given number of trials n and the given success probability p. Then find the mean, variance, and standard deviation. 18. n = 10, p = 0.2, P(1) 20. n = 14, p = 0.3, P(8) 22. n = 6, p = 0.8, P(6) 24. n = 15, p = 0.9, P(14 or more) 26. n = 30, p = 0.9, P(More than 27)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT