第五章第四十五题(统计:计算平均值和标准方差)(Statistics: compute mean and standard deviation)
- **5.45(统计:计算平均值和标准方差)在商务应用程序中经常需要计算数据的平均值和标准方差。平均值就是数字的简单平均。标准方差则是一个统计数字,给出了在一个数字集中各种数据距离平均值的聚集紧密度。例如,一个班级的学生的平均年龄是多少?年龄相差近吗?如果所有的学生都是同龄的,那么方差为0。编写一个程序,提示用户输入10个数字,然后运用下面的公式,显示这些数字的平均值及标准方差。
下面是一个运行示例:
Enter 10 numbers: 1 2 3 4.5 5.6 6 7 8 9 10
The mean is 5.61
The standard deviation is 2.99794
**5.45(Statistics: compute mean and standard deviation)In business applications, you are often asked to compute the mean and standard deviation of data. The mean is simply the average of the numbers. The standard deviation is a statistic that tells you how tightly all the various data are clustered around the mean in a set of data. For example, what is the average age of the students in a class? How close are the ages? If all the students are the same age, the deviation is 0. Write a program that prompts the user to enter 10 numbers and displays the mean and standard deviations of these numbers using the following formula: