Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

p.this.digit.at.n

Probability of a digit at the nth position


Description

It calculates the probability of digit "d" at the "n"th position.

Usage

p.this.digit.at.n(d,n)

Arguments

d

a digit from 0 to 9 (except at position n=1, where d cannot be 0, it wil give you NA).

n

the nth position.

Value

The probability of d at position n.

Examples

p.this.digit.at.n(1,1) # 0.30103
p.this.digit.at.n(1,2) # 0.1138901
p.this.digit.at.n(9,3) # 0.09826716
matrix <- as.data.frame(round(sapply(1:4, function(x) sapply(0:9,p.this.digit.at.n,n=x)),5))
names(matrix) <- paste0("n=",1:4)
rownames(matrix) <- paste0("d=",0:9)
matrix # a table with the probabilities of digits 0 to 9 in positions 1 to 4.

benford.analysis

Benford Analysis for Data Validation and Forensic Analytics

v0.1.5
GPL-3
Authors
Carlos Cinelli
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.