How to use the vega-statistics.sampleCurve function in vega-statistics

To help you get started, we’ve selected a few vega-statistics examples, based on popular ways it is used in public projects.

github vega / vega / packages / vega-regression / src / Regression.js View on Github external
add = p => {
              const t = {};
              for (let i=0; i<names.length; ++i) {
                t[names[i]] = g.dims[i];
              }
              t[as[0]] = p[0];
              t[as[1]] = p[1];
              values.push(ingest(t));
            };

      if (method === 'linear') {
        // for linear regression we only need the end points
        dom.forEach(x => add([x, model.predict(x)]));
      } else {
        // otherwise return trend line sample points
        sampleCurve(model.predict, dom, 25, 200).forEach(add);
      }
    });
github vega / vega / packages / vega-transforms / src / KDE.js View on Github external
groups.forEach(g => {
      const density = randomKDE(g, bandwidth)[method],
            scale = _.counts ? g.length : 1,
            local = domain || extent(g);

      sampleCurve(density, local, minsteps, maxsteps).forEach(v => {
        const t = {};
        for (let i=0; i<names.length; ++i) {
          t[names[i]] = g.dims[i];
        }
        t[as[0]] = v[0];
        t[as[1]] = v[1] * scale;
        values.push(ingest(t));
      });
    });
github vega / vega / packages / vega-transforms / src / Density.js View on Github external
var dist = parseDist(_.distribution, source(pulse)),
        minsteps = _.steps || _.minsteps || 25,
        maxsteps = _.steps || _.maxsteps || 200,
        method = _.method || 'pdf';

    if (method !== 'pdf' && method !== 'cdf') {
      error('Invalid density method: ' + method);
    }
    if (!_.extent && !dist.data) {
      error('Missing density extent parameter.');
    }
    method = dist[method];

    var as = _.as || ['value', 'density'],
        domain = _.extent || extent(dist.data()),
        values = sampleCurve(method, domain, minsteps, maxsteps).map(v => {
          var tuple = {};
          tuple[as[0]] = v[0];
          tuple[as[1]] = v[1];
          return ingest(tuple);
        });

    if (this.value) out.rem = this.value;
    this.value = out.add = out.source = values;
  }

  return out;
};

vega-statistics

Statistical routines and probability distributions.

BSD-3-Clause
Latest version published 7 months ago

Package Health Score

87 / 100
Full package analysis

Similar packages