ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[Âà¶K] ¤G¶µ¦¡¤À§G

[Âà¶K] ¤G¶µ¦¡¤À§G

Option Explicit
Public n As Integer, p As Single, x As Integer
'­pºâ²Å¦X¤G¶µ¦¡¤À§G¨Æ¥óªº·§²v
'n¡G¸ÕÅ禸¼Æ
'p¡G¤@¦¸¸ÕÅ礤¨Æ¥óA¥X²{ªº·§²v
'x¡Gn¦¸¸ÕÅ礤¨Æ¥óA¥X²{ªº¦¸¼Æ
'Bin¡G¨Æ¥óA¥X²{x¦¸ªº·§²v
Public Sub Bino(n As Integer, p As Single, x As Integer, bin As Double)
    Dim Q As Single, NN As Double, NI As Double, M As Double
    Dim I As Integer, C As Double
    Q = 1 - p
    If x = 0 Then
        bin = Q ^ n
        Exit Sub
    End If
    NN = 0
    For I = 1 To n
        NN = NN + Log(I)
    Next I                                              'NN = n!
    M = 0
    For I = 1 To x
        M = M + Log(I)
    Next I                                              'x!
    NI = 0
    For I = 1 To n - x
        NI = NI + Log(I)
    Next I                                              '(n-x)!
    C = NN - M - NI
    C = C + Log(p ^ x) + Log(Q ^ (n - x))
    bin = Exp(C)
End Sub

'­pºâ¤G¶µ¦¡¤À§G¨ç¼Æ
'n¡G¸ÕÅ禸¼Æ
'p¡G¤@¦¸¸ÕÅ礤¨Æ¥óA¥X²{ªº·§²v
'x¡G¨Æ¥óA¥X²{ªº¦¸¼Æ
'A(1,0 To x)¡G¨Æ¥ó·§²v
'A(2,0 To x)¡G¤U°¼·§²v¡A§Y¤À§G¨ç¼Æ
'A(3,0 To x)¡G¤W°¼·§²v
Public Sub ABino(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
        Bino 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
µ{¦¡¤H­û

        ÀR«ä¦Û¦b : ¹D¼w¬O´£ª@¦Û§Úªº©ú¿O¡A¤£¸Ó¬O¨þ¥¸§O¤HªºÃ@¤l¡C
ªð¦^¦Cªí ¤W¤@¥DÃD