You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Christoph Daniel Miksche 8f964a4db9
docs: add go report card
1 month ago
.github feat: implement firstDigit 5 months ago
.drone.yml init 5 months ago
.editorconfig init 5 months ago
.gitignore init 5 months ago
.pre-commit-config.yaml init 5 months ago
CONTRIBUTING.md feat: add countOccurrences 5 months ago
LICENSE feat: implement firstDigit 5 months ago
README.md docs: add go report card 1 month ago
go.mod feat: implement CalcBenfords 5 months ago
go.sum feat: implement CalcBenfords 5 months ago
main.go fix: export struct 5 months ago
main_test.go fix: export struct 5 months ago

README.md

benford

Build Status Go Report Card

Check if a number array confirms to the Benford's Law

Install

go get -u github.com/CMiksche/benford

Usage

Look at the tests for good examples.

E.g.:

import (
    "github.com/CMiksche/benford"
)

func example() {
    benfordResult := benford.CalcBenfords([]int{1, 2, 3, 4, 5, 6, 7, 8, 9})
    chiSquared := benfordResult.ChiSquared
    // 0.40105320411553363
    dist := benfordResult.Dist
    // distribution array of the numbers 1 to 9 in the input number array
}

The CalcBenfords().ChiSquared result is a float and describes how well Benford's Law was matched. Lower is better.

CalcBenfords().Dist returns the distribution of the numbers 1 to 9 in the input array.

Development

Install pre-commit hooks:

pre-commit install

Test program:

go test -v

See also