1166. Simple Statistics

单点时限: 2.0 sec

内存限制: 256 MB

Given a set of numerical data, there are several ways in which to describe it. One way is the so-called 5-number summary. The five numbers used to describe the data set are the following: the minimum value, the first quartile, the median, the third quartile and the maximum value. The definition of the minimum and maximum values are obvious. The median of a set of numbers is the value of the number which would lie exactly in the middle of the set if it were sorted. For example, the median of the data set 7,-1, 9, 4, 1 would be 4. If there is an even number of values in the set, then the median is the average of the two values closest to the middle; if our set contained the values 7,-1, 9, 4, 1, 0 then the median would be (1 + 4)/2 = 2.5. The definition of the quartiles follows naturally from the definition of the median. If we take all the values that come before the median in the sorted list (in the case when we average two values for the median this set would include the lower of those two numbers) the first quartile is the median of this set.

The definition of the third quartile is identical except it uses those values that come after the original median. In our example above with 7,-1, 9, 4, 1, 0, the first quartile value would be 0 (the median of the value -1, 1 and 0 which are less than 2.5) and the third quartile would be 7. If the data set contained 1, 2, 2, 2, 3 (in any order), then the median would be 2, and the first and third quartiles would be 1.5 and 2.5, respectively. One special case is when there is only one element in the list, in which case the quartiles are equal to the median. One other way to characterize data is its skewness. A distribution is considered right-skewed whenever the maximum value is farther from the median than the minimum value, or when the maximum and minimum are equally distant from the median, but the third quartile is farther from the median than the first quartile. A left-skewed distribution is one with the opposite situation. For our purposes, a distribution which is neither left-skewed nor right-skewed is considered symmetric. Your task for this problem is to read in various sets of numbers and output the 5-number summary for each, along with the skewness of the data.

输入格式

There will be multiple input sets. Each input set will consist of a single line of the form n v1 v2 v3 . . . vn where n is the number of data values, and v1, . . . , vn are the values. All the values will be integers and the maximum value for n will be 100. A line which begins with 0 indicates end of input and should not be processed.

输出格式

For each input set, output the 5-number summary and skewness in the order minimum, first quartile,median, third quartile, maximum and skew, with a single space between each. Skew will either be the phrase right-skewed, left-skewed or symmetric.

样例

Input
6 7 -1 9 4 1 0
15 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
15 15 14 13 12 11 10 9 8 7 6 5 4 3 2 0
0
Output
-1 0 2.5 7 9 right-skewed
1 4 8 12 15 symmetric
0 4 8 12 15 left-skewed

7 人解决,14 人已尝试。

7 份提交通过,共有 25 份提交。

7.3 EMB 奖励。

创建: 17 年,6 月前.

修改: 7 年,3 月前.

最后提交: 4 年前.

来源: partychen

题目标签