{"id":18486298,"url":"https://github.com/maxgfr/benford-law","last_synced_at":"2025-04-08T19:33:08.814Z","repository":{"id":64202326,"uuid":"574046804","full_name":"maxgfr/benford-law","owner":"maxgfr","description":"A simple library to check if a dataset follows the Benford's law","archived":false,"fork":false,"pushed_at":"2024-10-29T21:15:34.000Z","size":2020,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-30T01:02:32.364Z","etag":null,"topics":["algorithm","benford","benford-analysis","benfords-law","javascript","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/benford-law","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxgfr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-04T08:57:08.000Z","updated_at":"2024-10-29T21:15:03.000Z","dependencies_parsed_at":"2024-01-20T10:35:40.862Z","dependency_job_id":"708ad146-5593-409f-8e6e-8f20c93f21b6","html_url":"https://github.com/maxgfr/benford-law","commit_stats":{"total_commits":202,"total_committers":3,"mean_commits":67.33333333333333,"dds":"0.024752475247524774","last_synced_commit":"773ea1a13d6a782592d7716aa8c14155b6f65a65"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxgfr%2Fbenford-law","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxgfr%2Fbenford-law/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxgfr%2Fbenford-law/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxgfr%2Fbenford-law/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxgfr","download_url":"https://codeload.github.com/maxgfr/benford-law/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247730067,"owners_count":20986404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","benford","benford-analysis","benfords-law","javascript","nodejs","typescript"],"created_at":"2024-11-06T12:48:55.178Z","updated_at":"2025-04-08T19:33:08.453Z","avatar_url":"https://github.com/maxgfr.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# benford-law\n\nBenford's law is an observation that in many real-life sets of numerical data, the leading digit is likely to be small. In sets that obey the law, the number 1 appears as the leading significant digit about 30% of the time, while 9 appears as the leading significant digit less than 5% of the time. If the digits were distributed uniformly, they would each occur about 11.1% of the time. Benford's law also makes predictions about the distribution of second digits, third digits, digit combinations, and so on.\n\nTo get a better understanding of Benford's law, check out [this article](https://en.wikipedia.org/wiki/Benford%27s_law).\n\n## Installation\n\n```bash\nyarn add benford-law\n```\n\n## Usage\n\n```ts\nimport {\n  processBenfordLaw,\n  generateBenfordLawNumbers,\n  generateBenfordLawNumber,\n} from 'benford-law';\n\n// to generate a random number that follows Benford's law\nconsole.log(generateBenfordLawNumber());\n\n// to generate an array of 10 random numbers that follow Benford's law\nconsole.log(generateBenfordLawNumbers(10));\n\n// to process an array of numbers and get the distribution\nconsole.log(processBenfordLaw(generateBenfordLawNumbers(50000), 0.01));\n// {\n//   isFollowingBenfordLaw: true,\n//   firstDigitProbabilities: {\n//     '1': 0.29908,\n//     '2': 0.17694,\n//     '3': 0.1255,\n//     '4': 0.09742,\n//     '5': 0.0793,\n//     '6': 0.06712,\n//     '7': 0.0571,\n//     '8': 0.05124,\n//     '9': 0.0463\n//   },\n//   firstDigitCounts: {\n//     '1': 14954,\n//     '2': 8847,\n//     '3': 6275,\n//     '4': 4871,\n//     '5': 3965,\n//     '6': 3356,\n//     '7': 2855,\n//     '8': 2562,\n//     '9': 2315\n//   },\n//   firstDigitAccuracies: {\n//     '1': 0.0019199999999999773,\n//     '2': 0.0009399999999999964,\n//     '3': 0.0005000000000000004,\n//     '4': 0.0004200000000000037,\n//     '5': 0.0002999999999999947,\n//     '6': 0.00011999999999999511,\n//     '7': 0.000900000000000005,\n//     '8': 0.0002400000000000041,\n//     '9': 0.00030000000000000165\n//   }\n// }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxgfr%2Fbenford-law","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxgfr%2Fbenford-law","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxgfr%2Fbenford-law/lists"}