Grazie comunque per avere risposto.
Lo slope non è altro che il coefficiente angolare della retta calcolata tramite la regressione lineare
Non mi sembra importante di che tipo sia il parametro che passo alla funzione Slope ma se l'algoritmo che uso sia efficiente o ci sia un modo più performante.
Per informazione il coefficiente angolare tramite la regressione lineare si calcola in questo modo:
codice:Public Function Slope(ByVal Valori As Double(), ByVal Tempo As Double()) As Double Try Dim SommaVal As Double Dim SommaTemp As Double Dim SommaMulti As Double Dim SommaValSq As Double Dim SommaTempSq As Double For i As Integer = 0 To Valori.GetUpperBound(0) SommaVal += Valori(i) SommaTemp += Tempo(i) SommaMulti += Valori(i) * Tempo(i) SommaValSq += Valori(i) ^ 2 SommaTempSq += Tempo(i) ^ 2 Next i Return (Tempo.GetUpperBound(0) * SommaMulti - SommaVal * SommaTemp) / (Tempo.GetUpperBound(0) * SommaTempSq - (SommaTemp ^ 2)) Catch ex As Exception Throw New Exception(ex.Message) End Try End Function

Rispondi quotando