estion 2. Using a simulation with 10,000 trials, assign num_different to the number of times, in 10,000 trials, that two words picked unifor

Question

estion 2. Using a simulation with 10,000 trials, assign num_different to the number of times, in 10,000 trials, that two words picked uniformly at random (with replacement) from Pride and Prejudice have different lengths. Hint 1: What function did we use in section 1 to sample at random with replacement from an array? Hint 2: Remember that != checks for non-equality between two items.

in progress 0
Nevaeh 1 month 2021-10-14T01:23:02+00:00 1 Answer 0 views 0

Answers ( )

    0
    2021-10-14T01:24:29+00:00

    Answer:

    Done using Python programming language

    # Python function to simulate 10000 trials for two words to be picked

    # Comments are used for explanatory purpose

    # Program starts here

    Testsword = open(‘PrideAndPrejudice.txt’, encoding=’utf-8′).

    read()

    #The following line split the Testword

    splitwords = np.array(Testword.split())

    In []:

    # we’ll make use of a temporary variable here. It’ll be Initialise to 0

    Temp = 0

    # Here, the number of trials will be initialised to 0

    Init = 10000l0

    # Start iteration to search for possible words in PrideAndPrejudice

    for count in np.arange(Init):

    # search for 2 words

    Splitted = np.random.choice(Testword, 2)

    #implement the condition in hint above

    iflen(Splitted.item(0)) != len(Splitted.item(1)) != len(Spliitem(2)) != len(words.item(0)):

    #calcuate result

    Temp = Temp + 1

    num_different = Temp/Init

Leave an answer

45:7+7-4:2-5:5*4+35:2 =? ( )