Mean, median, mode and other statistical functions

From Computer Science Wiki
This a problem set for you to work through [1]

This is a problem set. Some of these are easy, others are far more difficult. The purpose of these problems sets are to HELP YOU THINK THROUGH problems. The solution is at the bottom of this page, but please don't look at it until you have tried (and failed) at least three or four times.

The Problem[edit]

Please program the following functions:

  1. Mean For a data set, the terms arithmetic mean, mathematical expectation, and sometimes average are used synonymously to refer to a central value of a discrete set of numbers: specifically, the sum of the values divided by the number of values.[2]
  2. Mode The mode is the value that appears most often in a set of data. [3]
  3. Median In statistics and probability theory, a median is the number separating the higher half of a data sample, a population, or a probability distribution, from the lower half. The median of a finite list of numbers can be found by arranging all the observations from lowest value to highest value and picking the middle one (e.g., the median of {3, 3, 5, 9, 11} is 5). If there is an even number of observations, then there is no single middle value; the median is then usually defined to be the mean of the two middle values[4]

Some Code to Get You Started[edit]

# this is a math problem-set

score_of_people_who_like_homemade_sushi=[2,3,3,2,3,2,3,9,2,3,4,8,1,2,8,7,6,5,8,9,1,2,3,2,1,4,3,2,1,4,5,4,1,6,9,6,1,4,2,3]

def mean(list):

    return mean

def mode(list):

    return mode

def median(list):

   return median

Take This Further[edit]

  1. plot (graphically - with ascii art) the range of numbers
  2. calculate the standard deviation of a range of numbers

How you will be assessed[edit]

Every problem set is a formative assignment. Please click here to see how you will be graded

References[edit]

One Possible Solution[edit]

Click the expand link to see one possible solution, but NOT before you have tried and failed!

Not yet :-)