什么是KS检验?
发布网友
发布时间:2022-04-25 22:03
我来回答
共1个回答
热心网友
时间:2022-06-17 23:08
假设x1,x2.......,xn,分别是n个灯泡的按时间顺序坏掉的时间,先求得其分布函数是y=f(x),
对其进行ks检验,
怎么求Dn值?怎么求相应的Dnα
下面有个不完整代码,我没看懂,哪个高手帮我改一下,并解释一下,不胜感激!
'计算任意给定显著度alpha时,精确的lamda值
Private Sub Command4_Click()
Dim k As Integer
Dim s1 As Double
Dim s2 As Double
Dim t As Double
Dim eps1 As Double
Dim q As Double
eps1 = 1E-80 '截断误差?
k = 0
s1 = 1
t = 1
Dim alpha As Double
Dim epsk As Double
epsk = 0.5
alpha = 0.05 '置信度(怎么设?从控件中取值?)
Dim P As Double
Dim gamma As Double
Dim lamda1 As Double
Dim lamda2 As Double
Dim z As Integer
Dim eps2 As Double
eps2 = 0.0000000001 'lamda的精度
gamma = 1 - alpha '置信度
lamda1 = 0
'给定Q(lamda)=1-alpha,计算反函数求lamda
Do
For z = 1 To 10000
z = z + 1
lamda2 = lamda1 + z * epsk
'求函数Q(lamda)
For k = 1 To 10000
k = k + 1
t = -t
s2 = 2 * t ^ Exp(-k * k * lamda2 * lamda2)
s1 = s1 + s2
If Abs(s2) < eps1 Then Exit For
Next k
P = s1
If (P - gamma) > 0 Then Exit For
Next z
lamda1 = lamda2 - epsk
epsk = 0.1 * epsk
Loop While Abs(lamda1 - lamda2) > eps2
Text2.Text = 0.5 * (lamda1 + lamda2) 'lamda
'计算DN值
End Sub