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

[Âà¶K] F¤À§Gªº¤À§G¨ç¼Æ--VB µ{¦¡½X

[Âà¶K] F¤À§Gªº¤À§G¨ç¼Æ--VB µ{¦¡½X

Attribute VB_Name = "modMethod"
Option Explicit
'­pºâF¤À§Gªº¤À§G¨ç¼Æ
'n1¡G¦Û¥Ñ«×¡A¤wª¾
'n2¡G¦Û¥Ñ«×¡A¤wª¾
'F¡GF­È¡A¤wª¾
'p¡G¤U°¼·§²v¡A©Ò¨D
'd¡G·§²v±K«×¡A©Ò¨D
Public Sub F_DIST(n1 As Integer, n2 As Integer, F As Double, _
            p As Double, d As Double)
    Dim x As Double, u As Double, Lu As Double
    Dim IAI As Integer, IBI As Integer, nn1 As Integer, nn2 As Integer
    Dim I As Integer
    Const PI As Double = 3.14159265359
    If F = 0 Then
        p = 0: d = 0: Exit Sub
    End If
    x = n1 * F / (n2 + n1 * F)
    If (n1 \ 2) * 2 = n1 Then
        If (n2 \ 2) * 2 = n2 Then
            u = x * (1 - x): p = x: IAI = 2: IBI = 2
        Else
            u = x * Sqr(1 - x) / 2: p = 1 - Sqr(1 - x): IAI = 2: IBI = 1
        End If
    Else
        If (n2 \ 2) * 2 = n2 Then
            p = Sqr(x): u = p * (1 - x) / 2: IAI = 1: IBI = 2
        Else
            u = Sqr(x * (1 - x)) / PI
            p = 1 - 2 * Atn(Sqr((1 - x) / x)) / PI: IAI = 1: IBI = 1
        End If
    End If
    nn1 = n1 - 2: nn2 = n2 - 2
    If u = 0 Then
        d = u / F
        Exit Sub
    Else
        Lu = Log(u)
    End If
    If IAI = n1 Then GoTo LL1
    For I = IAI To nn1 Step 2
        p = p - 2 * u / I
        Lu = Lu + Log((1 + IBI / I) * x)
        u = Exp(Lu)
    Next I
LL1:
    If IBI = n2 Then
        d = u / F: Exit Sub
    End If
    For I = IBI To nn2 Step 2
        p = p + 2 * u / I
        Lu = Lu + Log((1 + n1 / I) * (1 - x))
        u = Exp(Lu)
    Next I
    d = u / F
End Sub
µ{¦¡¤H­û

        ÀR«ä¦Û¦b : °µ¸Ó°µªº¨Æ¬O´¼¼z¡A°µ¤£¸Ó°µªº¨Æ¬O·Mè¡C
ªð¦^¦Cªí ¤W¤@¥DÃD