Sha256: 2d64a54780b49968caa4e625c537ec40f1a70470d4a470c8ca9a31c5a1a1a48e

Contents?: true

Size: 920 Bytes

Versions: 31

Compression:

Stored size: 920 Bytes

Contents

/* Inspired by Lee Byron's test data generator. */
function stream_layers(n, m, o) {
  if (arguments.length < 3) o = 0;
  function bump(a) {
    var x = 1 / (.1 + Math.random()),
        y = 2 * Math.random() - .5,
        z = 10 / (.1 + Math.random());
    for (var i = 0; i < m; i++) {
      var w = (i / m - y) * z;
      a[i] += x * Math.exp(-w * w);
    }
  }
  return d3.range(n).map(function() {
      var a = [], i;
      for (i = 0; i < m; i++) a[i] = o + o * Math.random();
      for (i = 0; i < 5; i++) bump(a);
      return a.map(stream_index);
    });
}

/* Another layer generator using gamma distributions. */
function stream_waves(n, m) {
  return d3.range(n).map(function(i) {
    return d3.range(m).map(function(j) {
        var x = 20 * j / m - i / 3;
        return 2 * x * Math.exp(-.5 * x);
      }).map(stream_index);
    });
}

function stream_index(d, i) {
  return {x: i, y: Math.max(0, d)};
}

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
picky-statistics-4.0.2 lib/picky-statistics/application/javascripts/d3/examples/stream/stream_layers.js
picky-statistics-4.0.1 lib/picky-statistics/application/javascripts/d3/examples/stream/stream_layers.js
picky-statistics-4.0.0 lib/picky-statistics/application/javascripts/d3/examples/stream/stream_layers.js
picky-statistics-4.0.0pre6 lib/picky-statistics/application/javascripts/d3/examples/stream/stream_layers.js
picky-statistics-4.0.0pre5 lib/picky-statistics/application/javascripts/d3/examples/stream/stream_layers.js
bum-0.0.17 public/d3/examples/stream/stream_layers.js
bum-0.0.16 public/d3/examples/stream/stream_layers.js
bum-0.0.15 public/d3/examples/stream/stream_layers.js
bum-0.0.14 public/d3/examples/stream/stream_layers.js
bum-0.0.13 public/d3/examples/stream/stream_layers.js
bum-0.0.12 public/d3/examples/stream/stream_layers.js