EXERCISE 1: Load this page into a separate browser window. Generate 10 random sequences of 3 letters and list them below. Were any of the 10 sequences real English words? Would you expect them to be?
EXERCISE 2: Modify the appropriate value in the page to generate 10 random sequences of 4 letters and list them below. Were any of the 10 sequences real English words? Would you expect them to be? Would you expect a 4-letter word be more or less likely than a 3-letter word? Explain.
EXERCISE 3: What would you expect to happen if you changed the contents of the box labeled "Letters to choose from" to only two letters, say "DC". What if you changed the contents to a single letter? Verify your predictions in the page.
EXERCISE 4: What would you expect to happen if you changed the number of sequences to be a negative number? What would you expect if the length of the sequences was specified as negative? Verify your predictions in the page.
Using the random sequence generator page, you can perform some interesting experiments. In particular, you can use this code as a tool for verifying or disproving hypotheses about word distributions, and to generate further data for analysis. First, consider the total number of unique 3-letter sequences that can be generated. Since each of the three positions in a sequence can be any of the 26 letters, there are 263 = 17,576 different sequences. Clearly, not all of these sequences form real words. The question arises: how many random 3-letter sequences would you expect to have to generate before you obtain a word?
EXERCISE 6: Use the Web page to generate 1000 random 3-letter sequences and count how many English words you obtain. List that number below. Hint: Since 1000 sequences will not fit on the screen at one time, generate the sequences in 10 groups of 100. Scanning 100 sequences for words can be done in just a few seconds.
Is the number you obtained close to the expected value of 28? If not, try generating another 500 or 1000 sequences and see if the approximation (number of words / number of sequences generated) improves.
As the length of the letter sequences increases, the chances of generating a word at random decreases dramatically. For example, there are 1,777 4-letter words in the online dictionary. Thus, the chances of generating a 4-letter word at random are 1 in 257 (1,777/264 = 1,777/456,976 = 1/257). For 5-letter sequences, the chances of generating a word at random is 1 in 4,920 (2,415/265 = 2,415/11,881,376 = 1/4,920) .
EXERCISE 7: Use the Web page to generate 1000 random 4-letter sequences and count how many English words you obtain. List that number below.
Since there is only a .38% chance of generating a 4-letter word at random, you would expect to obtain around 4 words out of 1000 random 4-letter sequences. Is the number you obtained close to 4? Compared to the case for 3-letter words, would you expect it to take more or fewer sequences to obtain a number close to the expected value? Explain.
Part of the blame for the scarcity of words among randomly generated sequences falls on letters such as 'q' and 'z'. Since these letters are used so infrequently in English, their inclusion in a random sequence of letters makes a real word extremely unlikely. If we exclude letters such as these, however, we can improve the chances of generating words considerably. For example, the 10 letters that appear most frequently in English text are "etaoinshrd". Random sequences of these letters would appear more likely to produce words.
EXERCISE 8: Modify the appropriate field in the Web page so that it generates random sequences using only the letters "etaoinshrd". Generate 1000 random 3-letter sequences of these letters and count how many English words you obtain. List that number below.
Is the number you obtained relatively consistent with the number obtained by the person sitting next to you (e.g., within 10% of each other)? If not, generate more sequences and add the word counts until your totals are closer.
Using your experimental results from the previous exercise, you should now be able to estimate the number of 3-letter words in the English language that use only the letters in "etaoinshrd". The followng general formula applies:
EXERCISE 9: Using the numbers you obtained in EXERCISE 8, estimate the number of 3-letter words in the English language that use only the letters in "etaoinshrd". Show your work in obtaining your estimate.
EXERCISE 10: Using the same approach as above, estimate the number of 4-letter words using only the letters "etaoinshrd". Show your work in obtaining your estimate.
Note: since there are many more 4-letter sequences than there are 3-letter sequences, it may take many more random generations in order to obtain a reasonable estimate. Justify your data.