VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Calculates the Geometric Mean of a series of numbers for use in statistical analysis, data mining o

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 Geometric Mean of a series of numbers for use in statistical analysis, data mining or data analysis.

Rate Calculates the Geometric Mean of a series of numbers for use in statistical analysis, data mining o



On Error GoTo ErrorHandler

'**********************************************************************************************************
'
'Purpose:           Algorithm that calculates the Geometric 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 geometric mean of a series of numbers
'                   for use in statistical analysis, data mining, data analysis and mathematical analysis.
'                   E.g. GeometricMean(20,10,5,8)
'
'Return Value:      The geometric mean of the series passed to the function.
'
'Return Type:       Variant
'
'
'
'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 header notice and this header notice
'                   has not been modified in any way. If this algorithm is used in a compiled form then
'                   the header notice 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 = 1                                               '
    
    
    For Each varNum In Numbers()
        If IsNumeric(varNum) And Not IsEmpty(varNum) Then       'Check if the variable is a valid number
            dblTotal = dblTotal * varNum                        'Multiply all the numbers in the series
            dblCount = dblCount + 1                             'Count the number of elements in the series
        Else
            Err.Raise vbObjectError + 1000, "www.paretoanalysts.com GeometricMean ", "Only numeric values can be used."
            Exit Function
        End If
    Next
    
    
    'The function that computes the root of a number is ^ in Visual Basic
    GeometricMean = (dblTotal ^ (1 / dblCount))
     
    
    
Exit_ErrorHandler:
    Exit Function
    
    
ErrorHandler:
    MsgBox Err.Number & " " & Err.Description, vbInformation, "www.paretoanalysts.com GeometricMean "
    Resume Exit_ErrorHandler
    
    
End Function


Download this snippet    Add to My Saved Code

Calculates the Geometric Mean of a series of numbers for use in statistical analysis, data mining o Comments

No comments have been posted about Calculates the Geometric Mean of a series of numbers for use in statistical analysis, data mining o. Why not be the first to post a comment about Calculates the Geometric Mean of a series of numbers for use in statistical analysis, data mining o.

Post your comment

Subject:
Message:
0/1000 characters