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 a08f52f5d8
docs: add benchmark blog post
4 months ago
.github docs: add github stuff 5 months ago
spec feat: first implementation 5 months ago
src feat: first implementation 5 months ago
.editorconfig feat: init 5 months ago
.gitignore feat: init 5 months ago
.travis.yml feat: init 5 months ago
LICENSE feat: init 5 months ago
README.md docs: add benchmark blog post 4 months ago
shard.yml fix: name 5 months ago

README.md

benfordslaw.cr

Build Status

A Crystal shard which provides a check if a number array confirms to the Benford's Law

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      benfordslaw:
        github: cmiksche/benfordslaw.cr
    
  2. Run shards install

Usage

require "benfordslaw"

Look at the tests for good examples. E.g.

test = BenfordsLaw::Check.new([1, 2, 3, 4, 5, 6, 7, 8, 9])
test.chiSquared.should eq(0.40105320411553363)

The BenfordsLaw::Check.chiSquared result is a float and describes how well Benford's Law was matched. Lower is better.

BenfordsLaw::Check.dist returns the distribution of the numbers 1 to 9 in the input array.

Development

Run tests:

crystal spec

Format:

crystal tool format

Contributing

  1. Fork it (https://github.com/CMiksche/benfordslaw.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

See also