Day 1: Basic Statistics - A Warmup

Objective

In this challenge, we practice calculating the mean, median, mode, standard deviation, and confidence intervals in statistics.

Task

Given a single line of N space-separated integers describing an array, calculate and print the following:

Mean (m): The average of all the integers.

Array Median: If the number of integers is odd, display the middle element. Otherwise, display the average of the two middle elements.

Mode: The element(s) that occur most frequently. If multiple elements satisfy this criteria, display the numerically smallest one.

Standard Deviation (σ)

Other than the modal values (which should all be integers), the answers should be in decimal form, correct to a single decimal point, 0.0 format. An error margin of ±0.1 will be tolerated for the standard deviation. The mean, mode and median values should match the expected answers exactly.

Assume the numbers were sampled from a normal distribution. The sample is a reasonable representation of the distribution. A user can approximate that the population standard deviation ≃ standard deviation computed for the given points with the understanding that assumptions of normality are convenient approximations.


In [30]:
# #Python Library Imports
import numpy as np
from scipy import stats

In [31]:
#count = int(raw_input())
#numbers = raw_input()
count = 10
numbers = "64630 11735 14216 99233 14470 4978 73429 38120 51135 67060"

arr_numbers = [int(var_num) for var_num in numbers.split()]

# #MEAN
print np.mean(arr_numbers)

# #MEDIAN
print np.median(arr_numbers)

# #MODE
print int(stats.mode(np.array(arr_numbers))[0])

# #STANDARD DEVIATION
print np.std(arr_numbers)


43900.6
44627.5
4978
30466.9475274

Day 1: Standard Deviation Puzzles #1

Objective

In this challenge, we practice calculating standard deviation.

Task

Find the largest possible value of N where the standard deviation of the values in the set {1,2,3,N} is equal to the standard deviation of the values in the set {1,2,3}.

Output the value of N, correct to two decimal places.


In [166]:
# #Input Sets
set_original = [1,2,3]

set_original_mean = np.mean(set_original)
set_original_std = np.std(set_original)

print set_original_mean, set_original_std


2.0 0.816496580928

In [167]:
np.std([1,2,3,2.94])


Out[167]:
$$0.815889085599$$

Day 1: Standard Deviation Puzzles #2

Objective

In this challenge, we practice calculating standard deviation.

Task

The heights of a group of children are measured. The resulting data has a mean of 0.675 meters, and a standard deviation of 0.065 meters. One particular child is 90.25 centimeters tall. Compute z, the number of standard deviations away from the mean that the particular child is.

Enter the value of z, correct to a scale of two decimal places.


In [170]:
var_2_mean = 0.675
var_2_std = 0.065

child = 0.9025

In [172]:
(child - var_2_mean)/var_2_std


Out[172]:
$$3.5$$

In [ ]: