Hi everyone.

we have an assignment that asks us to count the number of occurrences in a piped raw input text file and print it, calculate its phi statistic, the expected phi for english and the expected phi for random and then print them all out. also, at the end of out program we need to print out english if the value of the phi statistic of the textfile is closer to english and print out random, if the value of the textfile's phi is closer to expected random phi.

I was able to do count the characters occurrences with dictionary as well as to calculate the expected phi for english and random. I'm just having troubles with writing the code that would calculate the phi statistic of the text. I can do it by hand but have no idea on how to do it in python. here's the formula when doing it by hand: phi = f1 (f1 - 1) + f2 (f2 - 1) + ... + fn (fn - 1)

do i need to make a list or is there any other way.

thanks a lot.