rbenf: Random Sample Satisfying Benford's Law

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/Benford_tests.R

Description

Returns a random sample with length n satisfying Benford's law.

Usage

1
rbenf(n)

Arguments

n

Number of observations.

Details

This distribution has the density:

f≤ft(x\right)=\frac{1}{x\cdot ln≤ft(10\right)} \forall x\in[1,10]

Value

Returns a random sample with length n satisfying Benford's law.

Author(s)

Dieter William Joenssen Dieter.Joenssen@googlemail.com

References

Benford, F. (1938) The Law of Anomalous Numbers. Proceedings of the American Philosophical Society. 78, 551–572.

See Also

qbenf; pbenf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#Set the random seed to an arbitrary number
set.seed(421)
#Create a sample satisfying Benford's law
X<-rbenf(n=20)
#Look at sample
X
#should be
# [1] 6.159420 1.396476 5.193371 2.064033 7.001284 5.006184
#7.950332 4.822725 3.386809 1.619609 2.080063 2.242473 1.944697 5.460581
#[15] 6.443031 2.662821 2.079283 3.703353 1.364175 3.354136

Example output

 [1] 6.159420 1.396476 5.193371 2.064033 7.001284 5.006184 7.950332 4.822725
 [9] 3.386809 1.619609 2.080063 2.242473 1.944697 5.460581 6.443031 2.662821
[17] 2.079283 3.703353 1.364175 3.354136

BenfordTests documentation built on May 1, 2019, 8:07 p.m.