algo-risk-benford

Solid

"Apply Benford's Law to detect anomalies in numerical datasets by analyzing first-digit frequency distributions. Use this skill when the user needs to audit financial data for fraud indicators, validate data integrity, or detect fabricated numbers — even if they say 'data manipulation detection', 'first digit test', or 'accounting fraud screening'.".

AI & Automation 22 stars 8 forks Updated 6 days ago MIT

Install

View on GitHub

Quality Score: 84/100

Stars 20%
45
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Benford's Law Analysis ## Overview Benford's Law predicts that in naturally occurring datasets, the leading digit d appears with probability P(d) = log₁₀(1 + 1/d). Digit 1 appears ~30.1% of the time, digit 9 only ~4.6%. Deviations from this distribution may indicate data fabrication or manipulation. Analysis runs in O(n). ## When to Use **Trigger conditions:** - Auditing financial data (expenses, invoices, tax returns) for manipulation - Screening large datasets for data integrity issues - Detecting fabricated or artificially rounded numbers **When NOT to use:** - For assigned/sequential numbers (zip codes, phone numbers, IDs) - For datasets with constrained ranges (e.g., human ages, percentages) - For small datasets (< 500 records — insufficient statistical power) ## Algorithm ``` IRON LAW: Benford's Law Applies to NATURALLY OCCURRING Data Spanning Orders of Magnitude Data that doesn't span multiple orders of magnitude (e.g., temperatures in Celsius, human heights) will NOT follow Benford's Law. Deviation from Benford's in such data is EXPECTED, not suspicious. Always verify the data type is appropriate before concluding fraud. ``` ### Phase 1: Input Validation Extract leading digits from dataset. Filter: remove zeros, negatives (take absolute value), values < 10. Verify dataset spans multiple orders of magnitude. **Gate:** 500+ records, data spans at least 2 orders of magnitude. ### Phase 2: Core Algorithm 1. Extract first digit of each number 2. Count frequency ...

Details

Author
charlieviettq
Repository
charlieviettq/awesome-agent-skill
Created
2 months ago
Last Updated
6 days ago
Language
Python
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category