TizzyT

Difference -TizzyT

Apr 24th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.59 KB | None | 0 0
  1.     'Calculates the average difference between numbers
  2.     Public Function Difference(ParamArray values() As Decimal) As Decimal
  3.         If values.Length = 1 Then Return 0
  4.         If values.Length = 2 Then Return Math.Abs(values(0) - values(1))
  5.         Dim div As Decimal = 2D / ((values.Length - 1D) * values.Length)
  6.         Dim vLen As Integer = values.Length - 1
  7.         Dim result As Decimal = 0
  8.         For x = 0 To vLen
  9.             For y = (x + 1) To vLen
  10.                 result += Math.Abs(values(x) - values(y)) * div
  11.             Next
  12.         Next
  13.         Return result
  14.     End Function
Add Comment
Please, Sign In to add comment