UNPKG

@quartic/bokehjs

Version:

Interactive, novel data visualization

47 lines (36 loc) 1.32 kB
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; import { Transform } from "./transform"; import * as p from "core/properties"; import * as bokeh_math from "core/util/math"; export var Jitter = (function(superClass) { extend(Jitter, superClass); function Jitter() { return Jitter.__super__.constructor.apply(this, arguments); } Jitter.define({ mean: [p.Number, 0], width: [p.Number, 1], distribution: [p.Distribution, 'uniform'] }); Jitter.prototype.compute = function(x) { if (this.distribution === 'uniform') { return x + this.mean + ((bokeh_math.random() - 0.5) * this.width); } if (this.distribution === 'normal') { return x + bokeh_math.rnorm(this.mean, this.width); } }; Jitter.prototype.v_compute = function(xs) { var i, idx, len, result, x; result = new Float64Array(xs.length); for (idx = i = 0, len = xs.length; i < len; idx = ++i) { x = xs[idx]; result[idx] = this.compute(x); } return result; }; return Jitter; })(Transform);