benford

package module
v0.0.0-...-8f964a4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2020 License: MIT Imports: 1 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Benford

type Benford struct {
	Dist       []float64
	ChiSquared float64
}

Benford = result of the Benford's Test, Benford.Dist is a array with float64 which describe the distribution of the numbers 1 to 9, Benford.ChiSquared is a float and describes how well Benford's Law was matched. Lower is better.

func CalcBenfords

func CalcBenfords(numbers []int) Benford

CalcBenfords takes a array of integers and returns a struct with information about how well benfords law was matched

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL