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.
This exercise is part of the course
Introduction to Julia
Exercise instructions
- Import the
Statistics
package under the namests
. - Use the
mean()
function from theStatistics
package to find the mean ofbody_temps_c
. - Print the mean body temperature.
- Use the
mean()
function from theStatistics
package to find the mean ofheart_rates
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# 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")