Day 1: Basic Statistics - A Warmup
Objective
In this challenge, we practice calculating the mean, median, mode and standard deviation in statistics. Check out the Resources tab for helpful videos!
Task
Given a single line of space-separated integers describing an array, calculate and print the following:
Mean (m): The average of all the integers.
where is the element of the array.
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 ():
where is the element of the array.
Other than the modal values (which should all be integers), the answers should be in decimal form, correct to a single decimal point, format. An error margin of 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.
Scoring
Scoring is proportional to the number of test cases cleared.
Input Format
The first line contains an integer, , denoting the number of elements in the array.
The second line contains space-separated numbers describing the elements of the array.
Constraints
Output Format
A total of five lines are required (in the following order:
- Mean (format: 0.0) on the first line.
- Median (format: 0.0) on the second line.
- Mode(s) (numerically smallest integer in the case of multiple integers)
- Standard Deviation (format: 0.0)
Sample Input
10
64630 11735 14216 99233 14470 4978 73429 38120 51135 67060
Sample Output
43900.6
44627.5
4978
30466.9
xxxxxxxxxx
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
return 0;
}