by http://www.paretoanalysts.com (5 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 13th December 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Calculates the Harmonic Mean of a series of numbers for use in statistical analysis, data mining, data analysis and mathematical analysis.
On Error GoTo ErrorHandler
'***************************************COMMENTS SECTION******************************************************************
'
'Purpose: Algorithm that calculates the Harmonic Mean of a series of numbers.
'
'Argument(s): Numbers - a series of comma separated numbers.
'
'Source: http://www.paretoanalysts.com
'
'Author: Pareto Analysts
'
'Creation Date: December 1, 2001
'
'Description: Calculates the Harmonic Mean of a series of numbers
' for use in statistical analysis, data mining, data analysis and mathematical analysis.
' E.g. HarmonicMean(20,10,5,8)
'
'Return Value: The Harmonic Mean of the series passed to the function.
'
'Return Type: Double data type
'
'
'
'Warranty : No claim is made as to the accuracy or fitness of this algorithm. The use of this
' algorithm is at your own risk and choice and the author is not liable in anyway
' for its use or damages that may occur as a result of its use.
'
'Copyright: The use or distribution of this algorithm is free provided that it is
' used or distributed along with this COMMENTS SECTION and this COMMENTS SECTION
' has not been modified in any way. If this algorithm is used in a compiled form then
' this COMMENTS SECTION must also be placed in a readme.txt file
'
'Inquiries: Inquiries about this algorithm, data mining, statistical analysis and data analysis
' can be directed to http://www.paretoanalysts.com
'
'**********************************************************************************************************
Dim varNum As Variant
Dim dblTotal As Double
Dim dblCount As Double
dblCount = 0 'The number of elements in the array
dblTotal = 0 '
For Each varNum In Numbers()
If IsNumeric(varNum) And Not IsEmpty(varNum) Then 'Check if the variable is a valid number
varNum = (1 / varNum)
dblTotal = dblTotal + CDbl(varNum) 'Expressely convert variant data to double
dblCount = dblCount + 1
Else
Err.Raise vbObjectError + 1000, "www.paretoanalysts.com HarmonicMean ", "Only numeric values can be used."
Exit Function
End If
Next
HarmonicMean = (1 / (dblTotal / dblCount))
Exit_ErrorHandler:
Exit Function
ErrorHandler:
MsgBox Err.Number & " " & Err.Description, vbInformation, "www.paretoanalysts.com HarmonicMean"
Resume Exit_ErrorHandler
End Function
No comments have been posted about Calculates the Harmonic Mean of a series of numbers for use in statistical analysis, data mining, d. Why not be the first to post a comment about Calculates the Harmonic Mean of a series of numbers for use in statistical analysis, data mining, d.