Question: This question is in python 3. I generate the sample here according to the distribution. I am not sure how to do this question. The

This question is in python 3.This question is in python 3. I generate the sample here according

I generate the sample here according to the distribution.to the distribution. I am not sure how to do this question.

I am not sure how to do this question.

The probability of 6 being selected is very small. Let's write a function that can check whether a certain element (such as 6) is included in the sample. Your function should take in a sample in the form of an array and an element x, and return True or False. It must use a while loop. Then use your function to determine if 6 was in the sample of size 1000. Assign this result to a variable called is_six_in1. Hint: Go through each entry in the array until you find a 6.

The probability of 6 being selected is very small. Let's write a

If my sample does not contain any 6, continue generating larger and larger samples until you have one with exactly one 6 in it. Your solution must use a while loop. Assign the resulting sample size to a variable called final_sample_size. Hint 1: We have written a function that checks if 6 is in an array; can we use it? Hint 2: You don't need to try every possible sample size (1000, 1001, 1002, ...) inside your while loop. Doing so will take too long!

function that can check whether a certain element (such as 6) is

valuesmake_array (1,2,3,4,5,6) prob-of-value = make_array (0.1,0.2,0.3,0.4,0.5, 0.00001) normalizer - 1.0/sum (prob_of_value) prob-of-value-normalizer * prob-of-value # ensure probabilities sum to 1 distribution_table Table).with_columns( 'value, values, 'probability of value', prob_of_value) distribution table suntol le().with_columns value probability of value 0.0666662 0.133332 0.199999 0.266665 0.333331 6.66662e-06 2 3 4 valuesmake_array (1,2,3,4,5,6) prob-of-value = make_array (0.1,0.2,0.3,0.4,0.5, 0.00001) normalizer - 1.0/sum (prob_of_value) prob-of-value-normalizer * prob-of-value # ensure probabilities sum to 1 distribution_table Table).with_columns( 'value, values, 'probability of value', prob_of_value) distribution table suntol le().with_columns value probability of value 0.0666662 0.133332 0.199999 0.266665 0.333331 6.66662e-06 2 3 4

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!