This is going to be relatively quick...
Given a lower-case word as input, calculate the Pearson's Correlation Coefficient between the letter position of the word (nth letter within the word, x), and the letter position within the alphabet (nth letter of the alphabet, y).
where x and y are the respective data sets as explained above (and further below), and n is the length of the string.
Input: forty Output: 0.964406804
Letters: f o r t y Alphabet Number (y): 6 15 18 20 25 Letter Position (x): 1 2 3 4 5 Length of word (n): 5
Correlation coefficient is worked out from the above formula.
Input: bells Output: 0.971793199
Letters: b e l l s Alphabet Number (y): 2 5 12 12 19 Letter Position (x): 1 2 3 4 5 Length of word (n): 5
Correlation coefficient is once again worked out from the above formula.
- Input must provide the word as a lower-case alphabetic string with no spaces (assumed input). The delivery of this string is entirely up to you (file, STDIN, function, array, carrier pigeon, etc.)
- Output is in the form of a numeric that will, by the formula, provide r, such that -1 <= r <= 1. Delivery of the output, once again, is entirely up to you.
- No silly loop holes
- This is not code-golf, as I'm sure there will be many languages that may have native statistical functions. Instead, this will be a popularity contest, so most votes wins here, so make your entry count... I'll be throwing in a bounty for the most creative answer that attracts my attention a little later down the line...