Questions tagged [benfords-law]

Benford's law states that in lists of numbers from many (but not all) real-life sources of data, the leading digit is distributed in a specific, non-uniform way. According to this law, the first digit is 1 about 30% of the time, and larger digits occur as the leading digit with lower and lower frequency, to the point where 9 as a first digit occurs less than 5% of the time. This distribution of first digits is the same as the widths of gridlines on the logarithmic scale.

17 questions
10
votes
2 answers

Is there a random number distribution that obeys Benford's Law?

Python has a number of ways to generate different distributions of random numbers, see the documentation for the random module. Unfortunately they aren't terribly understandable without the appropriate math background, especially considering the…
Mark Ransom
  • 299,747
  • 42
  • 398
  • 622
5
votes
3 answers

Benford's Law in Java - how to make a math function into Java

I have a quick question. I am trying to make a fraud detection app in java, the app will be primarily based on Benford's law. Benford's law is super cool, it basically can be interpreted to say that in a real financial transaction the first digit is…
ohGosh
  • 539
  • 1
  • 7
  • 10
3
votes
4 answers

How to implement Benford's law in MATLAB

I want to implement a version of Benford's law (http://en.wikipedia.org/wiki/Benford%27s_law) that basically asks for the first digit of a number to do analysis on the distribution. 1934---> 1 0.04 ---> 4 -56 ---> 5 How do you do this in MATLAB?
user312141
  • 33
  • 3
2
votes
1 answer

R Benford Analysis

I'm using the benford.analysis package to explore the benford's law. I'm being asked to plot distribution of the first digit of any given data set and overlay it on a benford graph. Right now, i'm looking at the plot() of the benford.analysis…
bencampbell_14
  • 587
  • 2
  • 10
  • 32
2
votes
1 answer

Benford - Dataset with NA strings returns an error in extract.digits

I've a dataset of macroeconomic data like GDP, inflation, etc... where Rows=different macroeconomic indicators and columns=years Since some values are missing (ex: the GDP of any country in any year), they are charged as "NA". When I perform these…
Pablo
  • 21
  • 1
1
vote
1 answer

Benfords Law in Java

I am trying to create a application that will figure out how to find benfords law on a number in the nth position, and so far I haven't been able to do it. I can find it for the number in the first position but I'm not sure after that. Here is a…
Rmyers
  • 217
  • 4
  • 14
1
vote
1 answer

Benford’s Law by group in R

I am attempting to implement Benford’s Law using the benford.analysis package in R across all vendors’ invoices. Over the entire dataset the data confirms. I’m trying to find a way to group by vendor to determine if any individual vendor is…
coult
  • 117
  • 1
  • 2
  • 6
1
vote
1 answer

Is there a Python package hat allows to perform a Kolmogorov Smirnov test against the Newcomb-Benford distribution that I can install via conda?

I found this package for R: https://rdrr.io/cran/BenfordTests/man/ks.benftest.html It allows you to perform a Kolmogorov Smirnov test against the Benford distribution (https://en.wikipedia.org/wiki/Benford%27s_law) given a list of numbers. I am…
Johannes Walter
  • 1,069
  • 2
  • 10
  • 25
1
vote
0 answers

Benford's Law count leading digits from csv file

I am new to python and am writing a program that reads values from a .csv file, then displays a graph that shows the test results compared to the expected output for Benford's Law. The .csv file has loan values which I need to read in the 1st column…
Ngoni X
  • 145
  • 1
  • 1
  • 8
1
vote
1 answer

Benford's Law Program in Java

I am making a program in Java to see if the Benford's Law is actually true. I am using BigDecimal, but there was an error ever since I implemented it. import java.lang.*; import java.math.BigDecimal; public class BenfordLaw { public static int…
Jaden Lee
  • 115
  • 7
0
votes
0 answers

R function returning "Error in table(nothing to tabulate)"

I have these two functions intended to load a data set (https://pages.scinet.utoronto.ca/~ejspence/1710014201-eng.csv) and calculate the frequency of each first digit in the years columns # Function that loads the appropriate data load.data…
0
votes
0 answers

Benford analysis in python

I am trying to use python benfords-law 1.0.0 library, to do an analysis on some data. Documentation doesnt say that the array that I need to pass has to be integers, however, the analysis only runs if I pass integers. from benfordslaw import…
Manza
  • 2,109
  • 1
  • 27
  • 34
0
votes
1 answer

Problem with the output of chisq.test with R

I'm actually creating a package for the Benford Law (for academic purpose). And I'm trying to perform a goodness of fit with the "chisq.test". I've this vector : prop = [1377 803 477 381 325 261 253 224 184] That I want to compare with this…
0
votes
2 answers

C++ Benford's Law program.

So I have to write a program to => analyze three different data files, and try to confirm Benford’s law. You will create a console application that opens each file, counts the number of values that start with ‘1’, ‘2’, ‘3’, etc., and then outputs…
CrisL
  • 1
  • 1
0
votes
3 answers

Benford's law program

I have to write a program that proves Benford's Law for two Data lists. I think I have the code down for the most part but I think there are small errors that I am missing. I am sorry if this is not how the site is supposed to be used but I really…
user2240033
  • 71
  • 1
  • 8
1
2