Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Calculates the average difference between numbers
- Public Function Difference(ParamArray values() As Decimal) As Decimal
- If values.Length = 1 Then Return 0
- If values.Length = 2 Then Return Math.Abs(values(0) - values(1))
- Dim div As Decimal = 2D / ((values.Length - 1D) * values.Length)
- Dim vLen As Integer = values.Length - 1
- Dim result As Decimal = 0
- For x = 0 To vLen
- For y = (x + 1) To vLen
- result += Math.Abs(values(x) - values(y)) * div
- Next
- Next
- Return result
- End Function
Add Comment
Please, Sign In to add comment