0.0.9 • Published 3 years ago

benfordslaw v0.0.9

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

benfordslaw

Build Status npm version npm Coverage Branches Coverage Lines Coverage Functions Coverage Statements

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

Heavily inspired by https://github.com/target/huntlib

Install

npm i benfordslaw

Usage

Look at the tests for good examples.

E.g.:

import { BenfordsLaw } from 'benfordslaw';

const numbers = [1,2,3,4,5,6,7,8,9];
const benfords = new BenfordsLaw(numbers);

const chiSquared = benfords.getChiSquared();
// chiSquared = 0.40105320411553363
const probability = benfords.getProbability()?.toFixed(1);
// probability = 1.0

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

The Probability describes how relevant ChiSquared is. It should be >= 0.9

getDist() returns the distribution of the numbers.

Why TypeScript

With Types TypeScript adds a extra layer of security. I also use mainly TypeScript projects with this project so TypeScript just makes sense. And TS also compiles to JavaScript Code so JS projects also can use it.

General Information

License: MIT

Author: Christoph Daniel Miksche

See also

0.0.9

3 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago