Skip to content

Instantly share code, notes, and snippets.

View owendall's full-sized avatar

Owen Dall Sotomayor owendall

View GitHub Profile
@owendall
owendall / D3.js Force Layout Tutorial - Part 1 - 2016-07-21
Last active July 22, 2016 20:34 — forked from sathomas/README.md
Understanding D3.js Force Layout - 1: The Simplest Possible Graph
This is part of a series of examples that describe the basic operation of
the [D3.js](http://d3js.org) [force layout](https://github.com/mbostock/d3/wiki/Force-Layout).
Eventually they may end up in a blog post that wraps everything together.
The first example creates the simplest possible graph using a force layout.
The comments in the code walk through the steps in creating a force directed
graph.
Things start to get more interesting in the [next example](http://jsdatav.is/visuals.html?id=11560633).
@owendall
owendall / D3.js Force Layout Tutorial - Part 3 - 2016-07-21
Last active July 22, 2016 20:35 — forked from sathomas/README.md
Understanding D3.js Force Layout - 3: Seeing a Layout in Action
This is part of a series of examples that describe the basic operation of
the [D3.js](http://d3js.org) [force layout](https://github.com/mbostock/d3/wiki/Force-Layout).
Eventually they may end up in a blog post that wraps everything together.
If you missed the beginning of the series, here's a link to
[first example](http://jsdatav.is/visuals.html?id=11550728).
Before digging into the properties and options of the force layout, it's
helpful to understand how the layout works more generally. And although
there's some serious mathematics going on under the hood, the principle
is pretty simple: The layout moves the graph nodes around a little bit
@owendall
owendall / D3.js Force Layout Tutorial - Part 4 - 2016-07-21
Created July 22, 2016 20:35 — forked from sathomas/README.md
Understanding D3.js Force Layout - 4: linkDistance
This is part of a series of examples that describe the basic operation of
the [D3.js](http://d3js.org) [force layout](https://github.com/mbostock/d3/wiki/Force-Layout).
Eventually they may end up in a blog post that wraps everything together.
If you missed the beginning of the series, here's a link to
[first example](http://jsdatav.is/visuals.html?id=11550728).
Earlier examples looked at the operation of force layout from a (very)
high level. This example begins examining the important properties of
the force layout in more detail.
@owendall
owendall / D3.js Force Layout Tutorial - Part 5 - 2016-07-21
Created July 22, 2016 20:36 — forked from sathomas/README.md
Understanding D3.js Force Layout - 5: charge
This is part of a series of examples that describe the basic operation of
the [D3.js](http://d3js.org) [force layout](https://github.com/mbostock/d3/wiki/Force-Layout).
Eventually they may end up in a blog post that wraps everything together.
If you missed the beginning of the series, here's a link to
[first example](http://jsdatav.is/visuals.html?id=11550728).
The [previous example](http://jsdatav.is/visuals.html?id=83515b77c2764837aac2)
shows how `linkDistance` tells the force layout the desired distance
between connected nodes. It may seem strange that D3 doesn't simply
compel all links to be that distance. The force layout, however, takes
@owendall
owendall / D3.js Force Layout Tutorial - Part 6 - 2016-07-21
Last active July 22, 2016 20:37 — forked from sathomas/README.md
Understanding D3.js Force Layout - 6: charge (continued)
This is part of a series of examples that describe the basic operation of
the [D3.js](http://d3js.org) [force layout](https://github.com/mbostock/d3/wiki/Force-Layout).
Eventually they may end up in a blog post that wraps everything together.
If you missed the beginning of the series, here's a link to
[first example](http://jsdatav.is/visuals.html?id=11550728).
The [previous example](http://jsdatav.is/visuals.html?id=1ca23ee9588580d768aa)
shows how `charge` can influence the distance between connected nodes and
prevent the layout from achieving the desired `linkDistance`. That's not
the main purpose of the `charge` force, however. It exists mostly to
@owendall
owendall / D3.js Force Layout Tutorial - Part 7 - 2016-07-21
Last active July 22, 2016 20:38 — forked from sathomas/README.md
Understanding D3.js Force Layout - 7: linkStrength
This is part of a series of examples that describe the basic operation of
the [D3.js](http://d3js.org) [force layout](https://github.com/mbostock/d3/wiki/Force-Layout).
Eventually they may end up in a blog post that wraps everything together.
If you missed the beginning of the series, here's a link to
[first example](http://jsdatav.is/visuals.html?id=11550728).
An [earlier example](http://jsdatav.is/visuals.html?id=83515b77c2764837aac2)
introduced `linkDistance` as a key parameter for force layouts. It
sets the desired distance between any connected nodes. The force
layout includes an additional parameter that serves to modify the
@owendall
owendall / D3.js Force Layout Tutorial - Part 8 - 2016-07-21
Created July 22, 2016 20:38 — forked from sathomas/README.md
Understanding D3.js Force Layout - 8: gravity
This is part of a series of examples that describe the basic operation of
the [D3.js](http://d3js.org) [force layout](https://github.com/mbostock/d3/wiki/Force-Layout).
Eventually they may end up in a blog post that wraps everything together.
If you missed the beginning of the series, here's a link to
[first example](http://jsdatav.is/visuals.html?id=11550728).
The code in the previous examples has mentioned a property that D3 calls
_gravity._ The force layout uses this property to keep nodes from wandering
off the edges of the visualization, something they might otherwise do to
avoid overlap.
@owendall
owendall / D3.js Force Layout Tutorial - Part 9 - 2016-07-21
Created July 22, 2016 20:38 — forked from sathomas/README.md
Understanding D3.js Force Layout - 9: friction
This is part of a series of examples that describe the basic operation of
the [D3.js](http://d3js.org) [force layout](https://github.com/mbostock/d3/wiki/Force-Layout).
Eventually they may end up in a blog post that wraps everything together.
If you missed the beginning of the series, here's a link to
[first example](http://jsdatav.is/visuals.html?id=11550728).
The final parameter this series considers is `friction`. This parameter, which
ranges from 0 to 1, tells D3.js how much (if at all) to slow down the layout
at each iteration. With a value of 1, the layout never slows down, while a
value of 0 forces all the nodes to immediately stop.
This graph shows the top 25 jazz albums of all time (at least according to [one blogger](http://www.thejazzresource.com/top_25_jazz_albums.html).) Links between the albums represent musicians that played on both. Click on the nodes and the links for more information.
> Note: iTunes links are _not_ affiliate links.
This visualization is a real application of the [D3.js](http://d3js.org) [force layout](https://github.com/mbostock/d3/wiki/Force-Layout). It demonstrates some of the principles in a series on that layout. You can review that series beginning with the [first example](http://jsdatav.is/visuals.html?id=11550728).
@owendall
owendall / D3.js - Visualizing Bayes, MCMC Simulation - 2016-07-21
Last active July 22, 2016 20:46 — forked from sathomas/README.md
Visualizing Bayes, Markov Chain Monte Carlo
*** Forked from the original by Stephen A Thomas (sathomnas) ***
Thanks to the excellent [bayes.js](http://www.sumsar.net/blog/2015/12/bayes-js-a-small-library-for-doing-mcmc-in-the-browser/) library from Rasmus Bååth it's now possible to experiment with Bayesian statistics in JavaScript. We'll take advantage of that library in this series of posts, which demonstrate Bayesian statistics visually for anyone with a web browser.
This first post covers Markov Chain Monte Carlo (MCMC), algorithms which are fundamental to modern Bayesian analysis. MCMC is also critical to many machine learning applications. Since this is the first post, though, we'll start with a brief introduction to Bayesian statistics.
## Bayes' Rule in Probability
The simplest form of Bayesian analysis arises in probability, not statistics, in the form of _Bayes' Rule_ (or _Bayes' Theorem_). Bayes' Rule describes relationships between conditional probabilities. Formally, it says: