早教吧作业答案频道 -->其他-->
《《求相关系数的算法》》已知有两组数据,分别存放在数组A(100)和B(100)中,求计算两组数据的相关性和相关系数的算法,
题目详情
《《 求相关系数的算法 》》
已知有两组数据,分别存放在数组 A(100) 和 B(100)中,求计算两组数据的相关性和相关系数的算法,
已知有两组数据,分别存放在数组 A(100) 和 B(100)中,求计算两组数据的相关性和相关系数的算法,
▼优质解答
答案和解析
Private Sub Command1_Click()
Dim Aave As Single, Bave As Single, i As Integer, Sigma As Single, Sigma2 As Single, Rab As Single
Dim A() As String, B() As String, myStrA As String, myStrB As String
myStrA = "1,2,3,4,5,6,7,8" '把数组A的值赋给第一个字符串,数字间用英文逗号分开
myStrB = "8,7,6,5,4,3,2,1" '把数组B的值赋给第另一个字符串,数字间用英文逗号分开
A = Split(myStrA, ",")
B = Split(myStrB, ",")
For i = LBound(A) To UBound(A)
Aave = Aave + Val(A(i))
Bave = Bave + Val(B(i))
Next
Aave = Aave / (UBound(A) + 1)
Bave = Bave / (UBound(B) + 1)
For i = LBound(A) To UBound(A)
Sigma = Sigma + (A(i) - Aave) * (B(i) - Bave)
Sigma2 = Sigma2 + (A(i) - Aave) ^ 2 * (B(i) - Bave) ^ 2
Next
Rab = Sigma / Sqr(Sigma2)
MsgBox Rab
End Sub
Dim Aave As Single, Bave As Single, i As Integer, Sigma As Single, Sigma2 As Single, Rab As Single
Dim A() As String, B() As String, myStrA As String, myStrB As String
myStrA = "1,2,3,4,5,6,7,8" '把数组A的值赋给第一个字符串,数字间用英文逗号分开
myStrB = "8,7,6,5,4,3,2,1" '把数组B的值赋给第另一个字符串,数字间用英文逗号分开
A = Split(myStrA, ",")
B = Split(myStrB, ",")
For i = LBound(A) To UBound(A)
Aave = Aave + Val(A(i))
Bave = Bave + Val(B(i))
Next
Aave = Aave / (UBound(A) + 1)
Bave = Bave / (UBound(B) + 1)
For i = LBound(A) To UBound(A)
Sigma = Sigma + (A(i) - Aave) * (B(i) - Bave)
Sigma2 = Sigma2 + (A(i) - Aave) ^ 2 * (B(i) - Bave) ^ 2
Next
Rab = Sigma / Sqr(Sigma2)
MsgBox Rab
End Sub
看了 《《求相关系数的算法》》已知...的网友还看了以下:
选取关系中若干属性列组成新关系的代数运算称之为______。A.选中运算B.投影运算C.选择运算D. 2020-05-23 …
选取关系中若干属性组成新关系的代数运算称为______。A.选中运算B.投影运算C.选择运算D.搜索 2020-05-24 …
两个关系有若干相同属姓名等值连接,并去掉重复属性的关系代数运算称为()。A.取列运算B.投影运算C. 2020-05-24 …
为了研究高中学生中性别与对乡村音乐态度(喜欢和不喜欢两种态度)的关系,运用2×2列联表进行独立性检 2020-06-10 …
行线方程组的计算已知n维列向量α1,α2,.αn中,前n-1个向量线性相关,后n-1个向量线性无关 2020-07-26 …
关于常系数线性微分方程组的expAt的唯一性在矩阵论的理论中,计算一个矩阵的e指A次幂,得到的结果 2020-08-02 …
统计中常用相关系数,一来衡量两个变量x、y之间线性相关关系的强弱,其计算公式是r=ni=1(xi− 2020-08-02 …
对两个变量x、y进行线性回归分析,计算得到相关系数r=-0.9962,则下列说法中正确的是()A. 2020-08-02 …
关于衡量两个变量y与x之间线性相关关系的相关系数r与相关指数R2中,下列说法中正确的是()A.r越 2020-08-02 …
常温条件下,将SO2气体通入一定量NaOH溶液中,所得溶液呈中性,关于该溶液的判断错误的是()A.该 2020-11-27 …