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

In R: write a function that inputs a vector x and a number n and returns...
In R: write a function that inputs a vector x and a number n and returns the first n elements of x. When n is greater than length(x), your function should just return x. We are not allowed to use any control flow statements
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...
Write a function printTwoLargest() that inputs an arbitrary number of positive numbers from the user. The...
Write a function printTwoLargest() that inputs an arbitrary number of positive numbers from the user. The input of numbers stops when the first negative or zero value is entered by the user. The function then prints the two largest values entered by the user. If no positive numbers are entered a message to that effect is printed instead of printing any numbers. If only one number is inputted, only the largest is printed out (see 2nd example below). Sample output:...
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
This is a python question. Write a function mult_table(n) that consumes a natural number n and...
This is a python question. Write a function mult_table(n) that consumes a natural number n and returns the n+1 by n+1 multiplication table (where each entry in the inner list is equal to the product of which list it is and the inner list position number, or in other words, the product of the row and column numbers). Use accumulative recursion. def mult_table(n) ''' Returns the n+1 by n+1 multiplication table    mult_table: Nat => (listof (listof Nat))    Examples:...
In MATLAB Write a function to create an array of N numbers with a normal distribution....
In MATLAB Write a function to create an array of N numbers with a normal distribution. Call that from a script to create 1000 numbers, with a mean of 50 and a sigma of 10.
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}.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT