Write scripts containing simple for-loops
summation i to N [ (Xi - mean of X)/ SDx * (Yi - mean of Y) / SDy ] r = ------------------------------------------------------------------------ ( N - 1 )As you will recall:
SD = sqrt( summation i to N (Yi - mean)2 / (N - 1) )So calculating r requires several steps:
X = ( 3, 5, 6, 7, 10, 12 ) mean of X = 7.17 Y = ( 5, 6, 7, 9, 10, 13 ) mean of Y = 8.33
SDx = [ (3-7.17)2+(5-7.17)2+(6-7.17)2+(7-7.17)2+(10-7.17)2+(12-7.17)2 ] / 5 SD = 1.48 SDx = [ (5-8.33)2+(6-8.33)2+(7-8.33)2+(9-8.33)2+(10-8.33)2+(13-8.33)2 ] / 5 SD = 1.32
r = [((3-7.17)/1.48*(5-8.33)/1.32)/5+((5-7.17)/1.48*(6-8.33)/1.32)/5+((6-7.17)/1.48*(7-8.33)/1.32)/5+((7-7.17)/1.48*(9-8.33)/1.32)/5+((10-7.17)/1.48*(10-8.33)/1.32)/5+((12-7.17)/1.48*(13-8.33)/1.32)/5 ] / 5 r = 0.978
Nonparametric Methods
Statistical methods that do not make assumptions about the distribution of the population are called nonparametric tests. Most nonparametric ideas are based on a simple idea. List the values in order from low to high, and assign each value a rank. Base all further analyses on the ranks. By analyzing ranks rather than values, you don't need to care about the distribution of the population.
PYTHON: For Loops
This is a fairly simple iterative construct:
ASSIGNMENT: