Question: Materials needed to answer the questions below: You can use one of two approaches: 1 ) add suitable code below and then

Materials needed to answer the questions below:
""" You can use one of two approaches:
1) add suitable code below and then run this file
2) run this file first then do the calculation in the
# LFS: ILO redundancy level (thousands): UK,1995 to 2022
# Source dataset ID LMS
# Unit 000's
# LFS: ILO redundancy level (thousands): UK: Men
redundancy_men=[108,110,101,111,116,107,115,121,104,88,91,90,78,106,
156,100,85,92,74,62,65,68,61,50,60,125,56,46]
# LFS: ILO redundancy level (thousands): UK: Women
redundancy_women=[67,57,54,59,62,63,62,64,54,53,51,48,50,59,79,55,63,
58,51,46,43,46,42,43,46,103,50,28]
import math
def median(alist):
""" Calculates the median of a list of numbers.
The list must not be empty.
"""
number_of_values = len(alist)
sorted_list = sorted(alist)
# Two cases, depending on whether the number of values is odd or even.
quotient = number_of_values //2
remainder = number_of_values %2
if (remainder ==1):
result = sorted_list[quotient]
else:
result =(sorted_list[quotient -1]+ sorted_list[quotient])/2
return result
def test_median():
assert median([2])==2
assert median([4,3])==3.5
assert median([3,1,8,4,7,6,4,2,5,9])==4.5
assert median([7,2,6,2,5,3,1,0,8,6,6,4,9])==5
# Unit test
test_median()
def mean(list):
"""Return mean of list"""
sum =0
count =0
for item in list:
sum = sum + item
count = count +1
return sum / count
def test_mean():
list =[1,2,3,4,5]
assert(mean(list)==3)
# Unit test
test_mean()
def corr_coef(list_x, list_y):
""" Return correlation between values in list_x and list_y.
Lists must be of equal length.
"""
x_bar = mean(list_x)
y_bar = mean(list_y)
sxy =0
sxx =0
syy =0
for index in range(len(list_x)):
x = list_x[index]
y = list_y[index]
sxy = sxy +(x - x_bar)*(y - y_bar)
sxx = sxx +(x - x_bar)*(x - x_bar)
syy = syy +(y - y_bar)*(y - y_bar)
return sxy / math.sqrt(sxx * syy)
def test_corr_coef():
# Data from M140 Unit 9 Example 5
list1=[78.9,75.8,77.3,74.2,78.1,72.8,77.6,77.9]
list2=[56.7,53.1,56.1,55.9,54.1,48.6,59.4,54.0]
assert round(corr_coef(list1, list2),2)==0.64
# Unit test
test_corr_coef()
Questions:
a)
i. Why might it be important to consider median redundancy levels in addition to mean values? How might outliers affect the interpretation of mean values compared to median values? Use information from attached picture.
ii.
Use this function provided above to find the median of redundancy_men.
In your Solution give the median, also provide the Python code you used for calling the median() function and explain how you executed it.
iii. The median redundancy level for women is 54,000. Identify two factors that may contribute to the difference in median redundancy levels between men and women in the United Kingdom. Use provided materials from above
b)
i. Use function provided above to calculate the correlation coefficient between redundancy_men and redundancy_women.
In your Solution, provide the resulting figure rounded (manually or using Python) to three decimal places. Also provide the Python code you used for calling the corr_coef() function and explain how you executed it.
ii.Briefly discuss whether any effect you have found is likely to be causal.
Materials needed to answer the questions below: "

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!