Variance in a array of words
Description:
Consider X as the aleatory variable that count the number of letters in a word. Write a function that, give in input an array of words (strings), calculate the variance of X. Max decimal of the variance : 4.
Some wiki: Variance , Aleatory variable
Example:
Consider "Hello" and "World":
X is { 5 } with P(X = 5) = 1 because the two words have the same length.
So E[X] = 5 x 1 = 5 and the standard formula for variance is E[(X - u)^2] so 1 x (5-5)^2 = 0
or you can calculate with the other formula E[X^2] - E[X]^2 = 5^2 x 1 - 5^2 = 0
Consider "Hi" and "World":
X is { 2, 5 } with P(X = 5) = 1/2 and P(X = 2) = 1/2.
So E[X] = 5 x 1/2 + 2 x 1/2 = 3.5 and the standard formula for variance is E[(X - u)^2] so 1/2 x (2-3.5)^2 + 1/2 x (5 - 3.5)^2 = 2.25
or you can calculate with the other formula E[X^2] - E[X]^2 = (5^2 x 1/2 + 2^2 x 1/2) - 3.5^2 = 2.25
Similar Kata:
Stats:
Created | Sep 11, 2015 |
Published | Sep 12, 2015 |
Warriors Trained | 862 |
Total Skips | 50 |
Total Code Submissions | 1931 |
Total Times Completed | 435 |
Python Completions | 435 |
Total Stars | 29 |
% of votes with a positive feedback rating | 87% of 76 |
Total "Very Satisfied" Votes | 59 |
Total "Somewhat Satisfied" Votes | 14 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 14 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |