Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

179 lines (157 sloc) 6.939 kb
<!DOCTYPE html>
<html lang="en">
<head>
<title>Testing Benford's Law</title>
<meta charset="utf-8" />
<meta name="description" content="An experiment to test Benford's Law against large, publicly available datasets." />
<meta name="author" content="Jason Long (@jasonlong) and Bryce Thornton (@brycethornton)" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
<link href="/css/screen.css" media="screen, projection" rel="stylesheet" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-584195-8']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div id="container">
<aside>
<h1>Testing <b>Benford's Law</b></h1>
<p>Imagine a large dataset, say something like a list of every country
and its population.</p>
<table>
<thead>
<tr>
<th>Country</th>
<th>Population</th>
</tr>
</thead>
<tbody>
<tr>
<td>Afghanistan</td>
<td><em>2</em>9,117,000</td>
</tr>
<tr>
<td>Albania</td>
<td><em>3</em>,195,000</td>
</tr>
<tr>
<td>Algeria</td>
<td><em>3</em>5,423,000</td>
</tr>
<tr>
<td>Andorra</td>
<td><em>8</em>4,082</td>
</tr>
<tr>
<td>Angola</td>
<td><em>1</em>8,993,000</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>&nbsp;</td>
<td>&uarr; Leading digit</td>
</tr>
</tfoot>
</table>
<p>Chances are, the leading digit will be a <em>1</em> more often than
a <em>2</em>. And <em>2</em>s would probably occur more often than
<em>3</em>s, and so on.</p>
<p>This odd phenomenon is Benford's Law. If a set of values were truly
random, each leading digit would appear about <em>11%</em>
of the time, but Benford's Law predicts a logarithmic distribution.
It occurs so regularly that it is even used in fraudulent accounting
detection.</p>
<p>See the <a href="http://en.wikipedia.org/wiki/Benfords_law">Wikipedia article</a>
for a more thorough discussion.</p>
<p>This is a simple experiment to see how many large, publicly accessible datasets satisfy Benford’s Law.</p>
<p class="github">This site is on GitHub. Please <a
href="https://github.com/jasonlong/benfords-law">help out by forking
the project and adding more datasets</a>.</p>
<footer>
<p>
<a href="http://twitter.com/share" class="twitter-share-button" data-text="Testing the seemingly strange phenomenon of Benford's Law" data-count="horizontal" data-via="jasonlong" data-related="brycethornton">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</p>
<iframe src="http://www.facebook.com/plugins/like.php?app_id=177119802347764&amp;href=http%3A%2F%2Ftestingbenfordslaw.com&amp;send=false&amp;layout=button_count&amp;width=200&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:200px; height:21px;" allowTransparency="true"></iframe>
<dl id="credits">
<dt>Concept, Design, &amp; Frontend Development</dt>
<dd><a href="http://twitter.com/jasonlong">@jasonlong</a></dd>
<dt>Frontend Development &amp; Data Crunching</dt>
<dd><a href="http://twitter.com/brycethornton">@brycethornton</a></dd>
</dl>
</footer>
</aside>
<section>
<h6>Available Datasets</h6>
<span id="dataset-wrapper"><select id="dataset-options"></select></span>
<header>
<h2 id="dataset-description"></h2>
</header>
<h6>Leading digit frequency</h6>
<ol id="chart">
<li><span class="fill" data-value="0"></span></li>
<li><span class="fill" data-value="0"></span></li>
<li><span class="fill" data-value="0"></span></li>
<li><span class="fill" data-value="0"></span></li>
<li><span class="fill" data-value="0"></span></li>
<li><span class="fill" data-value="0"></span></li>
<li><span class="fill" data-value="0"></span></li>
<li><span class="fill" data-value="0"></span></li>
<li><span class="fill" data-value="0"></span></li>
</ol>
<p id="benford-prediction"><b>▲</b> Predicted by Benford's Law</p>
<table id="stats">
<tr>
<td>Number of Records</td>
<td id="num-records"></td>
</tr>
<tr>
<td>Min Value</td>
<td id="min-value"></td>
</tr>
<tr>
<td>Max Value</td>
<td id="max-value"></td>
</tr>
<tr>
<td>Orders of Magnitude</td>
<td id="orders-of-magnitude"></td>
</tr>
</table>
<h6>Data Source:</h6>
<p><a id="data-source" href="#"></a></p>
</section>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script src="/js/app.js"></script>
<script src="/js/respond.min.js"></script>
<!--[if (gte IE 6)&(lte IE 8)]>
<script src="/js/selectivizr-min.js"></script>
<![endif]-->
<script type="text/javascript">
var _gauges = _gauges || [];
(function() {
var t = document.createElement('script');
t.type = 'text/javascript';
t.async = true;
t.id = 'gauges-tracker';
t.setAttribute('data-site-id', '4fcf6f3a613f5d656c0000b4');
t.src = '//secure.gaug.es/track.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(t, s);
})();
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.