none
Chi-Square for determining the correct keyword RRS feed

  • Question

  • I am writing a C# program using Chi-square method to determine which is the correct keyword from a list.

    First of all, I'm not too sure if this way of coding is correct:

    1) Determine the total no of alphabets in the ciphertext (exclude all other symbols like commas, space, etc) - so, this is ciphertext.Length

    2) Count the no of letters for each alphabet in the ciphertext (Ci)

    (eg. a=97, b=15, c=103,....z=1)

    3) Compute Chi-Square value for each alphabet and sum them up.

    Chi-Square for letter i = ((Ci - Ei)^2) / Ei

    i = a to z

    Ei = count of letter x language letter frequency

    Eg. Count for letter 'a' = 97, Language letter frequency for English = 8.167%, Ciphertext.length = 1230

    Therefore, Chi-Square(a) = ((97 - 1230x0.01867)^2) / (1230x0.01867)

    Chi-Square for keyword 1 = Chi-Square(a) + Chi-Square(b) + .... Chi-Square(z)

    4) No. 3 is repeated for every keyword on the list. The lowest Chi-Square value will be deduced as the correct keyword.

    I feel that something is wrong with the computation above because different keywords are used for the same ciphertext while the ciphertext.length remain unchange in the formula. This will not generate different Chi-Square values.

    Also, should symbols other than alphabets be excluded from ciphertext.length?

    I know that Chi-square may not be the best method for deducing the correct keyword but it's a requirement of my assignment to use this.

    I would appreciate if someone could advise on this.

    Thanks.

    Thursday, January 31, 2013 3:01 AM

Answers

  • This is an online forum provided by Microsoft about their product "Microsoft Project".  You'll have better luck with your question if you re-post in a more appropriate forum. See http://www.microsoft.com/communities/forums/default.mspx or search via Google and/or Bing. 

    --rms www.rmschneider.com

    Thursday, January 31, 2013 8:05 AM

All replies

  • This is an online forum provided by Microsoft about their product "Microsoft Project".  You'll have better luck with your question if you re-post in a more appropriate forum. See http://www.microsoft.com/communities/forums/default.mspx or search via Google and/or Bing. 

    --rms www.rmschneider.com

    Thursday, January 31, 2013 8:05 AM
  • Sorry if this is not the appropriate forum but perhaps there is isn't any other forums that will suits this topic.

    Will you be able to advise?

    Thanks.

    Thursday, January 31, 2013 9:40 AM
  • : use Google, Bing

    : book on algorithms

    : local university statistics professor


    --rms www.rmschneider.com

    Thursday, January 31, 2013 9:45 AM
  • Is it possible to remove this thread then? Or shall I just leave it?
    Thursday, January 31, 2013 12:02 PM
  • I've marked the thread as answered.  Good luck finding a more suitable forum.
    Friday, February 1, 2013 11:36 AM
    Moderator
  • Thanks.
    Sunday, February 3, 2013 9:50 AM