Question: Python help please write function to calculate E(y) and Var(y) Only write Python Write a function that uses independent random samples to simulate the following

Python help please write function to calculate E(y) and Var(y)

Only write Python

Write a function that uses independent random samples to simulate the following approximate counting formulas. Number the samples randomly 1 through n.

Y = the number of subsets that test positive. p = probability of infection

I wrote function to make n and k. please look at the code for n and k. It's given already

Now Just write below formula only E(y) and Var(y) in python for calculating variance and estimate

Again only calculate E(y) and Var(y)Python help please write function to calculate E(y) and Var(y) Only write

Python Write a function that uses independent random samples to simulate the

Eimport sys #syamadulantamextractucansalamarguments from random import shuffle # random module to use shuffle method Ewith open('output.txt'a'w') as f: # open a file in the same directory in writing mode n = int(sys.argv[1]) # first argument n k = int(sys.argv[2]) #second argumentuk num_lines = int(sys.argv[3]) #third argument total number of lines to write data = ['0']*(n-k) + ['1']*k # create a initial list of n bits with k bits set for i in range(num_lines): # run a loop till num_lines shuffle(data) # shuffle the list f.write(''.join(data) + ' ') #print the listubxmconvertinguintomamstring #and add newline character i E[Y] = Ep; where p; = 1 ("+T6/23/) E[2'] = [](1 + p;) i E[4'] = [](1 + 3p;) Var(2%) = E[4'] - (E[2'])? i Eimport sys #syamadulantamextractucansalamarguments from random import shuffle # random module to use shuffle method Ewith open('output.txt'a'w') as f: # open a file in the same directory in writing mode n = int(sys.argv[1]) # first argument n k = int(sys.argv[2]) #second argumentuk num_lines = int(sys.argv[3]) #third argument total number of lines to write data = ['0']*(n-k) + ['1']*k # create a initial list of n bits with k bits set for i in range(num_lines): # run a loop till num_lines shuffle(data) # shuffle the list f.write(''.join(data) + ' ') #print the listubxmconvertinguintomamstring #and add newline character i E[Y] = Ep; where p; = 1 ("+T6/23/) E[2'] = [](1 + p;) i E[4'] = [](1 + 3p;) Var(2%) = E[4'] - (E[2'])

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!