数理统计程序集

源代码在线查看: 泊松分布m.bas

软件大小: 2183 K
上传用户: jjjjjkkkkjkjkjk
关键词: 数理统计 程序
下载地址: 免注册下载 普通下载 VIP

相关代码

				Attribute VB_Name = "modMethod"
				'泊松分布
				Option Explicit
				'计算符合泊松分布事件的概率
				'n:试验次数
				'p:一次试验中事件A出现的概率
				'x:n次试验中事件A出现的次数
				'Poi:事件A出现x次的概率
				Public Sub Poisson(n As Integer, p As Single, x As Integer, Poi As Double)
				    Dim L As Double, E As Double, X1 As Double, I As Integer
				    X1 = 0
				    For I = 1 To x
				        X1 = X1 + Log(I)
				    Next I
				    L = n * p
				    E = x * Log(L) - L - X1
				    Poi = Exp(E)
				End Sub
				
				'计算泊松分布函数
				'n:试验次数
				'p:一次试验中事件A出现的概率
				'x:事件A出现的次数
				'A(1,0 To x):事件概率
				'A(2,0 To x):下侧概率,即分布函数
				'A(3,0 To x):上侧概率
				Public Sub APoisson(n As Integer, p As Single, x As Integer, A() As Double)
				    Dim y As Integer, B As Double
				    B = 0
				    For y = 0 To x
				        Poisson n, p, y, A(1, y)
				        B = B + A(1, y)
				        If B > 1 Then B = 1
				        A(2, y) = B
				        A(3, y) = 1 - B
				    Next y
				End Sub
				
							

相关资源