EXCEL里面如何用函数求协方差?

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/22 16:46:54
EXCEL里面如何用函数求协方差?EXCEL里面如何用函数求协方差?EXCEL里面如何用函数求协方差?OptionExplicitOptionBase1PrivateSubCommandButton1

EXCEL里面如何用函数求协方差?
EXCEL里面如何用函数求协方差?

EXCEL里面如何用函数求协方差?
Option Explicit
Option Base 1
Private Sub CommandButton1_Click()
Dim i%,j%,k%,p(6),s(6,6)
For i = 1 To 6
p(i) = Sheet1.Cells(1070,i)
Next i
For i = 1 To 6
For j = 1 To 6
s(i,j) = 0
For k = 1 To 1070
s(i,j) = s(i,j) + (Sheet1.Cells(k,i) - p(i)) * (Sheet1.Cells(k,j) - p(j))
Next k
s(i,j) = s(i,j) / 1069
Sheets("Sheet2").Cells(i,j) = s(i,j)
If i <> j Then Sheets("Sheet2").Cells(j,i) = s(i,j)
Next j
Next i
End Sub