<VB数理统计实用算法>书中的算法源程序
源代码在线查看: 双因素f2.frm
VERSION 5.00
Begin VB.Form frmCalculate
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "双因素方差分析"
ClientHeight = 6870
ClientLeft = 60
ClientTop = 450
ClientWidth = 5760
LinkTopic = "Form1"
ScaleHeight = 6870
ScaleWidth = 5760
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdExit
Caption = "退 出"
Height = 375
Left = 1080
TabIndex = 1
Top = 0
Width = 1095
End
Begin VB.CommandButton cmdCheck
Caption = "检 验"
Height = 375
Left = 0
TabIndex = 0
Top = 0
Width = 1095
End
Begin VB.Label lblDB
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 120
TabIndex = 17
Top = 6000
Width = 5415
End
Begin VB.Label Label8
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "列因素的检验结论"
BeginProperty Font
Name = "隶书"
Size = 26.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 615
Left = 0
TabIndex = 16
Top = 5400
Width = 5415
End
Begin VB.Label lbl001B
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 4200
TabIndex = 15
Top = 4800
Width = 1455
End
Begin VB.Label Label7
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "显著性水平为0.01的列因素临界值:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 120
TabIndex = 14
Top = 4800
Width = 4095
End
Begin VB.Label lbl005B
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 4200
TabIndex = 13
Top = 4200
Width = 1455
End
Begin VB.Label Label6
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "显著性水平为0.05的列因素临界值:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 0
TabIndex = 12
Top = 4200
Width = 4215
End
Begin VB.Label lblFB
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 4200
TabIndex = 11
Top = 3600
Width = 1455
End
Begin VB.Label Label5
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "列因素检验值:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 600
TabIndex = 10
Top = 3600
Width = 3615
End
Begin VB.Label lblDA
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 240
TabIndex = 9
Top = 3000
Width = 5055
End
Begin VB.Label Label4
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "行因素的检验结论"
BeginProperty Font
Name = "隶书"
Size = 26.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 495
Left = 120
TabIndex = 8
Top = 2400
Width = 5295
End
Begin VB.Label lbl001A
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 4200
TabIndex = 7
Top = 1800
Width = 1455
End
Begin VB.Label lbl005A
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 4200
TabIndex = 6
Top = 1200
Width = 1455
End
Begin VB.Label lblFA
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 4200
TabIndex = 5
Top = 600
Width = 1455
End
Begin VB.Label Label3
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "显著性水平为0.01的行因素临界值:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 120
TabIndex = 4
Top = 1800
Width = 4095
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "显著性水平为0.05的行因素临界值:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 120
TabIndex = 3
Top = 1200
Width = 4095
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "行因素检验值:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 480
TabIndex = 2
Top = 600
Width = 3735
End
End
Attribute VB_Name = "frmCalculate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'双因素方差分析
Option Explicit
Private Sub Form_Load()
Label1.Visible = False: Label2.Visible = False
Label3.Visible = False: Label4.Visible = False
Label5.Visible = False: Label6.Visible = False
Label7.Visible = False: Label8.Visible = False
lblFA.Visible = False: lblDA.Visible = False
lbl001A.Visible = False: lbl005A.Visible = False
lblFB.Visible = False: lblDB.Visible = False
lbl001B.Visible = False: lbl005B.Visible = False
End Sub
'检验
Private Sub cmdCheck_Click()
Dim F1 As Double, F2 As Double
Dim sngF1 As Single, sngF2 As Single
Dim F005A As Double, F001A As Double
Dim sngF005A As Single, sngF001A As Single
Dim F005B As Double, F001B As Double
Dim sngF005B As Single, sngF001B As Single
Dim M1 As Integer, M2 As Integer
Dim m As Integer, p As Integer, n As Integer
Dim UA As Integer, UB As Integer, Ue As Integer
Label1.Visible = True: Label2.Visible = True
Label3.Visible = True: Label4.Visible = True
Label5.Visible = True: Label6.Visible = True
Label7.Visible = True: Label8.Visible = True
lblFA.Visible = True: lblDA.Visible = True
lbl001A.Visible = True: lbl005A.Visible = True
lblFB.Visible = True: lblDB.Visible = True
lbl001B.Visible = True: lbl005B.Visible = True
DoubleE V, F1, F2 '计算F检验值,F1是列因素,F2是行因素
sngF1 = F1: sngF2 = F2
lblFB.Caption = Str(sngF1): lblFA.Caption = Str(sngF2)
m = UBound(V, 1): p = UBound(V, 2): n = m * p
UB = p - 1: UA = m - 1: Ue = UA * UB
PF_DIST UB, Ue, 0.05, F005B '计算显著性为0.05的列因素临界值
PF_DIST UB, Ue, 0.01, F001B '计算显著性为0.01的列因素临界值
sngF005B = F005B: sngF001B = F001B
lbl005B.Caption = Str(sngF005B): lbl001B.Caption = Str(sngF001B)
If F1 If F1 > F005B And F1 If F1 > F001B Then lblDB = "列因素对试验指标的影响特别显著"
PF_DIST UA, Ue, 0.05, F005A '计算显著性为0.05的行因素临界值
PF_DIST UA, Ue, 0.01, F001A '计算显著性为0.01的行因素临界值
sngF005A = F005A: sngF001A = F001A
lbl005A.Caption = Str(sngF005A): lbl001A.Caption = Str(sngF001A)
If F2 If F2 > F005A And F2 If F2 > F001A Then lblDA = "行因素对试验指标的影响特别显著"
End Sub
'退出
Private Sub cmdExit_Click()
Unload Me
End
End Sub