I am writing a program which will use Chi-Square to determine which is the correct keyword for a ciphertext via Vigenère cipher.
I came across a website that describes the Chi-Square statistics in a rather simplistic manner and had also written some code to achieve my goals. However, the actual keyword does not seem to be the lowest chi-square value as according to the website. I'm not sure if the method as describe is correct or not.
The Chi-squared Statistic is a measure of how similar two categorical probability distributions are. If the two distributions are identical, the chi-squared statistic is 0, if the distributions are very different, some higher number will result. The formula for the chi-squared statistic is:
where CA is the count (not the probability) of letter A, and EA is the expected count of letter A.
This page will describe the use of the chi-squared statistic for cryptanalysis. Ordinarily, statisticians use the chi-squared statistic for measuring the goodness of fit of data. Unlike statisticians, we make no assumptions about the distribution of our data, and draw no conclusions about the significance of the result. We simply use the method to suggest a possible decryption.
Would someone be able to provide some advice on this?