1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
Function correl(mat As Variant) As Double
Dim nbval As Long
Dim somx As Double
Dim somy As Double
Dim somxy As Double
Dim somx2 As Double
Dim somy2 As Double
Dim boucle As Long
Dim tempo As Double
For boucle = 1 To UBound(mat)
If IsNumeric(mat(boucle, 1)) And IsNumeric(mat(boucle, 2)) Then
nbval = nbval + 1
somx = somx + mat(boucle, 1)
somy = somy + mat(boucle, 2)
somxy = somxy + (mat(boucle, 1) * mat(boucle, 2))
somx2 = somx2 + (mat(boucle, 1) * mat(boucle, 1))
somy2 = somy2 + (mat(boucle, 2) * mat(boucle, 2))
End If
Next boucle
tempo = (nbval * somxy) - (somx * somy)
tempo = tempo / Sqr(((nbval * somx2) - (somx * somx)) * ((nbval * somy2) - (somy * somy)))
correl = tempo
End Function |
Partager