Arithmetic Mean is a visual basic algorithm used in statistical analysis, data mining or data analy
Arithmetic Mean is a visual basic algorithm used in statistical analysis, data mining or data analysis for calculating the Arithmetic Mean of
Rate Arithmetic Mean is a visual basic algorithm used in statistical analysis, data mining or data analy
(2(2 Vote))
On Error GoTo ErrorHandler
'***********************************************************************
'
'Purpose: Algorithm that calculates the average of a series of numbers.
'
'Argument(s): Numbers - comma separated list of numbers.
'
'Source: http://www.paretoanalysts.com
'
'Author: Pareto Analysts
'
'Creation Date: December 1, 2001
'
'Description: Calculates the arithmetic mean or average of a series of numbers
' for use in statistical analysis, data mining or data analysis.
' E.g. ArithmeticMean(200,345,444,666)
'
'Return Value: The arithmetic mean of the series passed to the function
'
'Return Type: Variant
'
'
'***********************************************************************
Dim varNum As Variant
Dim varTotal As Variant
Dim varCount As Variant
'Count the number of elements in the array
varCount = 0
varTotal = 0
For Each varNum In Numbers()
If IsNumeric(varNum) And Not IsEmpty(varNum) Then 'Check if the variable is a valid number
varTotal = varTotal + varNum 'Add all the numbers
varCount = varCount + 1 'Count the number elements in the series
Else
Err.Raise vbObjectError + 1000, "www.paretoanalysts.com ArithmeticMean ", "Only numeric values can be used."
Exit Function
End If
Next
ArithmeticMean = (varTotal / varCount) 'Calculate the arithmetic mean or average
Exit_ErrorHandler:
Exit Function
ErrorHandler:
MsgBox Err.Number & " " & Err.Description, vbInformation, "www.paretoanalysts.com ArithmeticMean "
End Function
Arithmetic Mean is a visual basic algorithm used in statistical analysis, data mining or data analy Comments
No comments yet — be the first to post one!
Post a Comment