Question: Problem 8 : Weighted Means In this problem, we will create a function named mean ( ) that can be used to calculate either standard

Problem 8: Weighted Means
In this problem, we will create a function named mean() that can be used to calculate either standard means or weighted
means. The function will have two parameters, x and w. The parameter x is expected to be a numerical list, and w is
expected to be either a numerical list or to have the value None. If w=None, then the function should simply return the
mean (or average) of the elements in x. If w is a list, then the function should return the weighted mean of the elements in
x, using the elements of w as weights.
If the elements of x are denoted by 0,1,..., and the elements of w are denoted by 0,1,...,, then the weighted
mean is calculated as follows:
00+11++
0+1++
As an example (that you are not being asked to include in your notebook), if:
list1=[200,400,100]
list2=[3,2,5]
3(200)+2(400)+5(100)1900
Then weighted_mean(list1, list2) should return: ==190
3+2+5
10
5
\
 Problem 8: Weighted Means In this problem, we will create a

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 Databases Questions!