R 中的欺诈检测
Bart Baesens
Professor Data Science at KU Leuven
最好包含1000 个以上、跨越多个数量级的数值。
注意:数据不符合本福德定律是可能的。
若数据集对前两位数字服从本福德定律,则首两位 $D_1D_2$ 等于 $d_1d_2$ 的概率近似为:
$$P(D_1D_2=d_1d_2)=\log\left(1+\frac{1}{d_1d_2}\right) \qquad d_1d_2\in [10, 11, ..., 98, 99]$$
benlaw <- function(d) log10(1 + 1 / d)
benlaw(12)
0.03476211
此检验比首位数检验更可靠,最常用于欺诈检测。
bfd.cen <- benford(census.2009$pop.2009, number.of.digits = 2)
plot(bfd.cen)

expenses 含 1000 笔报销。benford.analysis 包中的函数。bfd1.exp <- benford(expenses, number.of.digits = 1)
plot(bfd1.exp)

bfd2.exp <- benford(expenses, number.of.digits = 2)
plot(bfd2.exp)

R 中的欺诈检测