#author("2024-09-26T15:59:06+09:00","default:ogiwiki","ogiwiki")
#author("2024-09-26T15:59:32+09:00","default:ogiwiki","ogiwiki")
**特徴語抽出 [#n06206b4]
***対数尤度比 Log-Likelihood Ratio [#o0791a7e]
-Excel用の関数(VBA)((Excelシートのlog関数とはちがってVBAではlog関数が自然対数(底がe)なのに注意。Excelだとln関数))
 Public Function LogLikelihood(ByVal target As Long, comparison As Long, targetTotal As Long, comparisonTotal As Long) As Variant
     a = target
     b = comparison
     c = targetTotal - a
     d = comparisonTotal - b
        
     If a = 0 Then aLNa = 0 Else aLNa = a * LN(a)
     If b = 0 Then bLNb = 0 Else bLNb = b * LN(b)
     
     LNLikelihood = 2 * (aLNa + bLNb + c * LN(c) + d * LN(d) - (a + b) * LN(a + b) - (a + c) * LN(a + c) - (b + d) * LN(b + d) - (c + d) * LN(c + d) + (a + b + c + d) * LN(a + b + c + d))
     
     If target / targetTotal < comparison / comparisonTotal Then LogLikelihood = LogLikelihood * (-1)
    
 End Function

-[[ダウンロード LLR.xlsm>https://www.dropbox.com/scl/fi/8ic4rpga43us6mu94rwlw/LLR.xlsm?rlkey=e8pro5oquwrpcbscexb2d6pvv&st=n8yej8g0&dl=1]]
-[[ダウンロード LLR.xlsm>https://www.ogiso.net/wiki/?plugin=attach&pcmd=open&file=LLR.xlsm&refer=%E6%8E%88%E6%A5%AD%E8%B3%87%E6%96%99%2F%E5%AF%BE%E6%95%B0%E5%B0%A4%E5%BA%A6%E6%AF%94%E3%81%AB%E3%82%88%E3%82%8B%E7%89%B9%E5%BE%B4%E8%AA%9E%E6%8A%BD%E5%87%BA]]

//-[[ダウンロード LLR.xlsm>https://www.dropbox.com/scl/fi/8ic4rpga43us6mu94rwlw/LLR.xlsm?rlkey=e8pro5oquwrpcbscexb2d6pvv&st=n8yej8g0&dl=1]]

--cf.[[『現代日本語書き言葉均衡コーパス』語彙表>https://ccd.ninjal.ac.jp/bccwj/bcc-chu.htm]]

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS