• Stars
    star
    133
  • Rank 272,600 (Top 6 %)
  • Language
    CSS
  • Created over 13 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Experimenting with Benford's Law

Testing Benford's Law

This is a simple experiment by Jason Long and Bryce Thornton to test how many real-life, publicly available datasets satisfy Benford's Law.

Contributing Datasets

If you find this to be an interesting idea, we'd encourage you to help add more datasets to the site. We've intentionally kept the site as simple and lightweight as possible. There is no real backend - the data has been crunched in advance and the results are simply entered into JSON files.

To contribute a new dataset, you'll need to do two things:

Add the dataset name to the JSON index file

The format of js/datasets/index.json is simply a key/value pair:

{
  "twitter-users-by-followers-count": "Twitter users by followers count",
  "distance-of-stars-from-earth-in-light-years": "Distance of stars from Earth in light years",
  "loan-amounts-on-kiva-org": "Loan amounts on kiva.org",
  "total-number-of-print-materials-in-us-libraries": "Total number of print materials in US libraries",
  "population-of-spanish-cities": "Population of Spanish cities"
}

Create a dataset JSON file

Add your new file in the /js/datasets/ directory with a name that matches the key used in step 1. The format looks like this:

{
	"values": {
		"1": 32.62,
		"2": 16.66,
		"3": 11.80,
		"4": 9.26,
  		"5": 7.63,
		  "6": 6.55,
		"7": 5.76,
		"8": 5.14,
		"9": 4.56
	},
	"num_records": "38,670,514",
	"min_value": "1",
	"max_value": "4,706,631",
	"source": "http://www.infochimps.com/datasets/twitter-census-twitter-users-by-friends-count"
}

It's important to include the source of the data used so that others can verify and reproduce the results.

Crunching the data

Generating Benford stats is a fairly straightforward process. We've made a simple ruby class for you to use if you'd like.

First, grab a copy of the class from here: https://gist.github.com/1044174

Second, include the class in your script like so:

require 'benford_counter'
require 'rubygems'
require 'csv'

counter = BenfordCounter.new

CSV.foreach("spain.txt") do |row|
  counter.count(row[9])
end

counter.results

Additional Tools

fweez contributed the Linux filesize dataset and created a Python script for tallying filesizes in a directory.

Updating Javascript and CSS

We're using CoffeeScript for the Javascript and Sass/Compass for the CSS.

Once CoffeeScript is installed (see the CoffeeScript docs), run this command from the project root to observe and compile changes:

coffee --watch -o js/ --compile js/coffee/*.coffee 

Note that the only file that should be edited is /js/coffee/app.coffee. The /js/coffee/app.js file is generated by CoffeeScript.

To make changes to the CSS, you need to install Sass and Compass (see the Compass docs. Then edit /css/sass/screen.scss. You observe and compile changes by running this command from the project root:

compass watch

To compile a production-ready compressed version:

compass compile --output-style compressed --force  

More Repositories

1

isometric-contributions

Browser extension for rendering an isometric pixel art version of your GitHub contribution graph.
JavaScript
3,395
star
2

cayman-theme

A responsive theme for GitHub Pages
CSS
1,505
star
3

geo_pattern

Create beautiful generative geometric background images from a string.
Ruby
1,256
star
4

mater

πŸ… A simple menubar Pomodoro app
JavaScript
524
star
5

lavalamp

A text editor theme that visually differentiates languages.
Vim Script
327
star
6

iterm2-icons

Replacement icon for iTerm2 or other macOS terminal apps. Designed for Big Sur.
242
star
7

jasonlong

HTML
180
star
8

architect-theme

Open Source version of the GitHub Pages theme
CSS
91
star
9

vim-replacement-icon

A simple and clean replacement icon for Vim.
39
star
10

vim-textobj-css

Vim text objects for CSS, Sass, etc.
Vim Script
33
star
11

tactile-theme

Open Source version of the GitHub Pages theme
CSS
29
star
12

dotfiles

Files. With dots in front of them.
Shell
28
star
13

blackantmedia

Portfolio site of Jason Long
PHP
26
star
14

jasonlong.me

My personal site
Astro
20
star
15

reddit-tighty-whities

A userstyle that strips Reddit down to the bare minimum.
CSS
10
star
16

json-contributions

Serverless function to get a JSON format of a user's GitHub contribution chart
JavaScript
10
star
17

iterm-clrs

An iTerm theme based on @mrmrs nicer color palette for the web.
9
star
18

3d-contributions

JavaScript
7
star
19

training-cert-generator

Command line tool for generating PDF training certificates
Ruby
7
star
20

next.js-three.js-demo

JavaScript
7
star
21

nord-iterm2

A slightly higher-contrast version of Nord
4
star
22

ultisnippets

My snippets for Ultisnip in Vim
3
star
23

backups-ui

Static templates for backups UI
JavaScript
3
star
24

processing-fm

Experiments with Processing.js and Last.FM API
JavaScript
2
star
25

cinecastfilms.com

JavaScript
2
star
26

pixelbits

A daily creative coding exercise.
HTML
1
star
27

sell.github.io

CSS
1
star
28

responsive-actions-logs

Small Node app to prototype a responsive version of the Actions log view
HTML
1
star
29

pixel-hubbers

Pixelcat experiment with three.js
JavaScript
1
star
30

nugit

Quick spike of refreshing git-scm.com with Tachyons
CSS
1
star
31

dynamic-favicons

JavaScript
1
star
32

brave-replacement-icon

macOS replacement icon for Brave
1
star