开始使用免费开始使用

Using the Statistics package

Now that you know how to import and use packages, you can analyze the data from the last chapter even further.

The array body_temps_c, which you created in the last chapter, is available in the environment. This array contains some measurements of body temperatures in degrees Celsius.

Another array named heart_rates is also available in your environment and contains the heart rates of the same sample of people measured in beats per minute.

You want to find the average value of each of these arrays. You know that inside the Statistics package, there is a function called mean(), which will calculate exactly what you want.

本练习是课程的一部分

Introduction to Julia

查看课程

练习说明

  • Import the Statistics package under the name sts.
  • Use the mean() function from the Statistics package to find the mean of body_temps_c.
  • Print the mean body temperature.
  • Use the mean() function from the Statistics package to find the mean of heart_rates.

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Import the Statistics package
____

# Calculate the mean body temperature
mean_body_temp_c = ____(____)

# Print the mean body temperature
println("The mean body temperature is ", ____)

# Calculate the mean heart rate
mean_heart_rate = ____(____)

println("The mean heart rate is $mean_heart_rate")
编辑并运行代码