3. Here is a Python dictionary of the relative frequency of letters in English t
ID: 3870857 • Letter: 3
Question
3. Here is a Python dictionary of the relative frequency of letters in English text: [ "A": .08167, "B": .01492, "C" .02782, "D": .04253, "E": .12702, "F": .02228, ''G": .02015, "H": .06094 , '' I '': .06996 , "J'' : .00153 , "K": .00772 , ''L'' : .04025, "M": .02406, "N":.06749, "0": .07507, "P": .01929, "Q": .00095, "R": .05987, "S": .06327, "T": .09056, "U": .02758, "V": .00978, "W": .02360, "X": .00150, "Y": .01974, "Z": .00074 Here is some plaintext: ethicslawanduniversitypolicieswarningtodefendasystemyouneedtobeabletot hinklikeanattackerandthatincludesunderstandingtechniquesthatcanbeusedt ocompromisesecurityhoweverusingthosetechnlquesintherealworldmayv1olate thelawortheuniversitysrulesanditmaybeunethicalundersomecircumstancesev enprobingforweaknessesmayresultinseverepenaltiesuptoandincludingexpuls ioncivilfinesandjailtimeourpolicyineecsisthatyoumustrespecttheprivacya ndpropertyrightsofothersatalltimesorelseyouwillfailthecourseactinglawf ullyandethicallyisyourresponsibilitycarefullyreadthecomputerfraudandab useactcfaaafederalstatutethatbroadlvcriminalizescomputerintrusionthisi soneofseverallawsthatgovernhackingunderstandwhatthelawprohibitsifindou btwecanreferyoutoanattorneypleasereviewitsspoliciesonresponsibleuseoft echnologyresourcesandcaenspolicydocumentsforguidelinesconcerningproper The population variance of a finite population X of size N and mean is given by Xi- (a) What is the population variance of the relative letter frequencies in English text? (b) What is the population variance of the relative letter frequencies in the given plaintext?Explanation / Answer
a)
dic={'A': 8.167, 'B': 1.492, 'C': 2.782, 'D': 4.253, 'E': 12.702, 'F': 2.228, 'G': 2.015,
'H': 6.094, 'I': 6.996, 'J': 0.153, 'K': 0.772, 'L': 4.025, 'M': 2.406, 'N': 6.749,
'O': 7.507, 'P': 1.929, 'Q': 0.095, 'R': 5.987, 'S': 6.327, 'T': 9.056, 'U': 2.758,
'V': 0.978, 'W': 2.360, 'X': 0.150, 'Y': 1.974, 'Z': 0.074}
s=0
for k,v in dic.items():
s+=(1-v/100)**2
population_variance=s/26
print(population_variance)
b)
text='ethicslawanduniversitypolicieswarningtodefendasystemyouneedtobeabletothinklikeanattackerandthatincludesunderstandingtechniquesthatcanbeusedtocompromisesecurityhoweverusingthosetechniquesintherealworldmayviolatethelawortheuniversitysrulesanditmaybeunethicalundersomecircumstancesevenprobingforweaknessesmayresultinseverepenaltiesuptoandincludingexpulsioncivilfinesandjailtimeourpolicyineecsisthatyoumustrespecttheprivacyandpropertyrightsofothersatalltimesorelseyouwillfailthecourseactinglawfullyandethicallyisyourresponsibilitycarefullyreadthecomputerfraudandabuseactcfaaafederalstatutethatbroadlycriminalizescomputerintrusionthisisoneofseverallawsthatgovernhackingunderstandwhatthelawprohibitsifindoubtwecanreferyoutoanattorneypleasereviewitsspoliciesonresponsibleuseoftechnologyresourcesandcaenspolicydocumentsforguidelinesconcerningproper'
l=sorted(list('qwertyuiopasdfghjklzxcvbnm'))
freq=[]
for k in l:
freq.append(text.count(k))
n=len(text)
s=0
for k in freq:
s+=(1-k/840)**2
population_variance=s/26
print(population_variance)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.