Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pos < 0 results in incorrect probabilities #13

Open
danielmccarville opened this issue May 20, 2024 · 1 comment
Open

Pos < 0 results in incorrect probabilities #13

danielmccarville opened this issue May 20, 2024 · 1 comment

Comments

@danielmccarville
Copy link

benfordslaw() returns incorrect expected probabilities when pos < 0. This shows up clearly in the Example info: https://erdogant.github.io/benfordslaw/pages/html/Examples.html#last-digit-test.

The Example where pos=-1 shows that the the last digit is expected to be '1' about 30% of the time. That's not true. It appears to be using the formula for the first significant digit, instead of using convolution to find the probability of the n-th digit.

Recommended solution would be to restrict pos > 0.

@danielmccarville danielmccarville changed the title Last Digit position returns wrong probabilities Pos < 0 results in incorrect probabilities May 20, 2024
@danielmccarville
Copy link
Author

Dug into the repo more to figure out what's happening. The init method in benfordslaw (line 52) uses the absolute value of pos. That's not intuitive, since the distribution of the first digit and the last digit aren't related at all. Similarly, the distribution of the second digit and second-to-last digit aren't the same.

I'd recommend removing that absolute value from all of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant