- 注册时间
- 2015-10-15
- 最后登录
- 1970-1-1
- 威望
- 星
- 金币
- 枚
- 贡献
- 分
- 经验
- 点
- 鲜花
- 朵
- 魅力
- 点
- 上传
- 次
- 下载
- 次
- 积分
- 2202
- 在线时间
- 小时
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?欢迎注册
×
大约 10 年前,本人开始学了一点 VB 编程,结合当时学的产品检验和可靠性方面的知识,依据国军标《火工品可靠性评估方法》GJB376-1987 中的方法,编写了一个 VB 程序,该程序的目的就是根据产品批量、抽验数量、试验(检验)失效数(不合格数)、以及规定的置信度,来判定该批产品的可靠度是多少。
该国军标适合于产品批量较大,抽验数量可以较多的情况。
- ' 成败型试验可靠度准确计算 计算依据:《火工品可靠性评估方法》GJB376-87
- Private Sub Form_Click()
- Open "批量500,抽50,失效1,置信度0.95.txt" For Output As 1 'R=0.912149
- nn = 500 '批量
- n = 50 '抽样数
- F = 1 '失效数
- D = 0.95 '置信度
-
-
- R1 = 0: R2 = 1 '根在这个范围
- pi = 3.1415926535: e = 2.718281828459
- Dim h(50)
- Dim B(50)
- B(2) = 1 / 6: B(4) = -1 / 30: B(6) = 1 / 42: B(8) = -1 / 30: B(10) = 5 / 66
- B(12) = -691 / 2730: B(14) = 7 / 6: B(16) = -3617 / 510: B(18) = 43867 / 798
- B(20) = -174611 / 330: B(22) = 854513 / 138: B(24) = -236364091 / 2730
- B(26) = 8553103 / 6: B(28) = -23749461029# / 870: B(30) = 8615841276005# / 14322
- B(32) = -7709321041217# / 510: B(34) = 2577687858367# / 6
- B(36) = -2.63152715530535E+19 / 1919190: B(38) = 2.92999391384156E+15 / 6
- B(40) = -2.61082718496449E+20 / 13530: B(42) = 1.52009764391807E+21 / 1806
- B(44) = -2.7833269579301E+22 / 690: B(46) = 5.96451111593912E+23 / 282
- B(48) = -5.60940336899782E+27 / 46410: B(50) = 4.9505720524108E+26 / 66
-
- GoTo 10
- 20: If y < 0 Then R1 = R: GoTo 10
- If y > 0 Then R2 = R: GoTo 10
-
- 10: k = k + 1
- R = (R1 + R2) / 2
-
- If nn > 100 Then GoTo 40
-
-
- x = nn * R: If x < 10 Then GoSub sub1: a1 = aaa 'a1 = (NR)!
- x = nn * R: If x >= 10 Then GoSub sub2: a1 = aaa
-
- x = nn * R - n: If x < 10 Then GoSub sub1: a2 = aaa 'a2 = (NR-n)!
- x = nn * R - n: If x >= 10 Then GoSub sub2: a2 = aaa
-
- a3 = 1 'a3 = (N)!/(N-n)!
- For i = nn - n + 1 To nn
- a3 = a3 * i
- Next i
-
- GoSub sub4
-
- y = a1 / a2 / a3 * z - (1 - D)
-
- GoTo 50
-
- 40: x = nn * R: GoSub sub3: L1 = LLL 'L1 = Log(NR)!
- x = nn - n: GoSub sub3: L2 = LLL 'L2 = Log(N-n)!
- x = nn: GoSub sub3: L3 = LLL 'L3 = Log(N)!
- x = nn * R - n: GoSub sub3: L4 = LLL 'L4 = Log(NR-n)!
- GoSub sub4
-
- y = L1 + L2 - L3 - L4 + Log(z) - Log(1 - D)
-
- 50: If k / 2 = Int(k / 2) And k <= 50 Then
- Print Tab(2); "k = "; k;: Print #1, Tab(2); "k = "; k;
- If y >= 0 Then
- Print Tab(12); "y="; Format(y, " ##0.000000000000000")
- Print #1, Tab(12); "y="; Format(y, " ##0.000000000000000")
- Else
- Print Tab(12); "y="; Format(y, "###0.000000000000000")
- Print #1, Tab(12); "y="; Format(y, "###0.000000000000000")
- End If
- End If
-
- If k < 40 Then GoTo 20
- If k >= 40 Then GoTo 30
-
- 30: Print: Print #1,
- Print Tab(12); "R = "; Format(R, "0.000000")
- Print #1, Tab(12); "R = "; Format(R, "0.000000")
- Print Tab(12); "y = "; Format(y, "0.00000000000000")
- Print #1, Tab(12); "y = "; Format(y, "0.00000000000000")
-
- 999: Close
- Exit Sub
- End
-
- sub1: '广义阶乘子程序
- nnn = 1000000
- aaa = 1
- For i = 1 To nnn
- If x + i = 0 Then x = -i + 0.00001
- aaa = aaa * i / (x + i)
- Next i
- aaa = aaa * nnn ^ x
- Return
-
- sub2: '用斯特林公式计算广义阶乘 x!
- c1 = (1 + 1 / (12 * x) + 1 / (288 * x ^ 2))
- c1 = c1 - 139 / (51840 * x ^ 3) - 571 / (2488320 * x ^ 4) + 163879 / (209018880 * x ^ 5)
- aaa = Sqr(2 * pi * x) * (x / e) ^ x * c1
- Return
-
- sub3: '用斯特林公式计算广义阶乘的对数
- If x <= 20 Then GoSub sub1: LLL = Log(aaa): Return
- c1 = 0
- For kv = 1 To 15 '25
- c = B(2 * kv) / (2 * kv) / (2 * kv - 1) / (x ^ (2 * kv - 1))
- c1 = c1 + c
- Next kv
-
- LLL = (x + 0.5) * Log(x) - x + Log(Sqr(2 * pi)) + c1
- Return
-
- sub4: '求系数 Z
- h(0) = 1
- For i = 1 To F
- h(i) = h(i - 1) * (n - i + 1) * (nn - nn * R - i + 1) / i / (nn * R - n + i)
- Next i
-
- z = 0
- For i = 0 To F
- z = z + h(i)
- Next i
- Return
-
- End Sub
-
-
复制代码
按此程序算出的结果,与上述国军标书中所载表格数据对照,二者结果相同。书中不可能把一切数据全都列入,例如批量是 495 就不会列入,只能查到 500。置信度也是分为几个档次,不可能列出所有的值。抽验数量也同样。因此当标准中缺少某些数据时,可以用此程序计算。
|
|