Learn About Calculating the Mean

This tutorial describes how to calculate the mean

Calculating the Mean

In data science, the arithmetic mean is known as the average. It is the central value in a finite data set of numbers. We can calculate the mean by finding the sum of all values in a dataset and divide it by the number of values.

x ¯ = 1 n i = 0 n x i

The arithmetic mean can be calculated in Quorum by using the helper action, Mean() within the DataFrame's class. To do this, we will use our 'frame' object and call the function Mean(). In this case we will be calculating the mean of the perimeter and the area of dry bean classifications. Here is a brief description on how Mean() works.

Mean Function
FunctionDescriptionUsage
dataFrameObject:Mean()This action calculates the mean of the column selected from the frame. Note that it can only calculate the mean of one column at a time.frame:Mean()

Here is some code on how to calculate the mean:

//We need the DataFrame class to load in files for Data Science operations.
use Libraries.Compute.Statistics.DataFrame

//Create a DataFrame, which is essentially a table that understands 
//more information about the data that is being loaded.
DataFrame frame

//This loads data relative to the project, so put the dryBeans file in the Data/Miscellaneous folder
frame:Load("../Data/Miscellaneous/DryBeans.csv")

//Tell the frame we want the first column selected
frame:AddSelectedColumn(0)
text someText = "Mean of the first column (Area) of dry beans:"
output someText
output frame:Mean()

Try it Yourself!

Press the blue run button to execute the code in the code editor. Press the red stop button to end the program. Your program will work when the console outputs "Build Successful!"

Congrats! We have just learned how to calulate the mean! To view the whole file, we can click here.

Next Tutorial

In the next tutorial, we will discuss median, which describes calculating the median.