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:
add suitable code below and then run this file
run this file first then do the calculation in the
# LFS: ILO redundancy level thousands: UK to
# Source dataset ID LMS
# Unit s
# LFS: ILO redundancy level thousands: UK: Men
redundancymen
# LFS: ILO redundancy level thousands: UK: Women
redundancywomen
import math
def medianalist:
Calculates the median of a list of numbers.
The list must not be empty.
numberofvalues lenalist
sortedlist sortedalist
# Two cases, depending on whether the number of values is odd or even.
quotient numberofvalues
remainder numberofvalues
if remainder :
result sortedlistquotient
else:
result sortedlistquotient sortedlistquotient
return result
def testmedian:
assert median
assert median
assert median
assert median
# Unit test
testmedian
def meanlist:
Return mean of list"""
sum
count
for item in list:
sum sum item
count count
return sum count
def testmean:
list
assertmeanlist
# Unit test
testmean
def corrcoeflistx listy:
Return correlation between values in listx and listy
Lists must be of equal length.
xbar meanlistx
ybar meanlisty
sxy
sxx
syy
for index in rangelenlistx:
x listxindex
y listyindex
sxy sxy x xbary ybar
sxx sxx x xbarx xbar
syy syy y ybary ybar
return sxy math.sqrtsxx syy
def testcorrcoef:
# Data from M Unit Example
list
list
assert roundcorrcoeflist list
# Unit test
testcorrcoef
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 redundancymen.
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 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 redundancymen and redundancywomen.
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 corrcoef function and explain how you executed it
iiBriefly discuss whether any effect you have found is likely to be causal.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
