How to use jstat - 10 common examples

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

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dojo / framework / tests / core / benchmark / runner / src / benchmarkRunner.ts View on Github external
function writeResult(res: Result, dir: string) {
	if (!fs.existsSync(dir)) {
		fs.mkdirSync(dir);
	}
	let benchmark = res.benchmark;
	let framework = res.framework.name;
	let data = res.results;
	data = data.slice(0).sort((a: number, b: number) => a - b);
	// data = data.slice(0, config.REPEAT_RUN - config.DROP_WORST_RUN);
	let s = jStat(data);
	console.log(
		`result ${fileName(
			res.framework,
			benchmark
		)} min ${s.min()} max ${s.max()} mean ${s.mean()} median ${s.median()} stddev ${s.stdev()}`
	);
	let result: JSONResult = {
		framework: framework,
		benchmark: benchmark.id,
		type: benchmark.type === BenchmarkType.CPU ? 'cpu' : 'memory',
		min: s.min(),
		max: s.max(),
		mean: s.mean(),
		median: s.median(),
		geometricMean: s.geomean(),
		standardDeviation: s.stdev(),
github Polymer / tachometer / src / stats.ts View on Github external
function confidenceInterval95(
    {mean, variance}: Distribution, size: number): ConfidenceInterval {
  // http://www.stat.yale.edu/Courses/1997-98/101/confint.htm
  const t = jstat.studentt.inv(1 - (.05 / 2), size - 1);
  const stdDev = Math.sqrt(variance);
  const margin = t * stdDev;
  return {
    low: mean - margin,
    high: mean + margin,
  };
}
github TwoRavens / TwoRavens / assets / app / solvers / wrapped.js View on Github external
mean: _ => _,
        prediction: x => (MSE * 1 / (m || 1)) + x,
    }[type]).map(Math.sqrt);

    let g = values.length;

    let statValue = {
        // simultaneous region over regression surface
        workingHotelling: Math.sqrt(ddof * jStat.centralF.inv(1 - alpha, ddof, n - ddof)),

        // simultaneous set
        scheffe: Math.sqrt(g * jStat.centralF.inv(1 - alpha, g, n - ddof)),
        bonferroni: jStat.studentt.inv(1 - alpha / (2 * g), n - ddof),

        // pointwise
        t: jStat.studentt.inv(1 - alpha / 2, n - ddof)
    }[statistic];

    let invLink = {
        gaussian: _ => _,
        poisson: x => Math.exp(x),
        exponential: x => -1 / x,
        gamma: x => -1 / x,
        binomial: x => 1 / (1 + Math.exp(x))
    }[family];

    return values
        .map((val, i) => [-1, 1].map(sign => invLink(val + sign * statValue * stdErr[i])).sort())
};
github TwoRavens / TwoRavens / assets / app / solvers / wrapped.js View on Github external
// MSE is already included in the coefficient variance-covariance matrix
    let stdErr = variances.map({
        mean: _ => _,
        prediction: x => (MSE * 1 / (m || 1)) + x,
    }[type]).map(Math.sqrt);

    let g = values.length;

    let statValue = {
        // simultaneous region over regression surface
        workingHotelling: Math.sqrt(ddof * jStat.centralF.inv(1 - alpha, ddof, n - ddof)),

        // simultaneous set
        scheffe: Math.sqrt(g * jStat.centralF.inv(1 - alpha, g, n - ddof)),
        bonferroni: jStat.studentt.inv(1 - alpha / (2 * g), n - ddof),

        // pointwise
        t: jStat.studentt.inv(1 - alpha / 2, n - ddof)
    }[statistic];

    let invLink = {
        gaussian: _ => _,
        poisson: x => Math.exp(x),
        exponential: x => -1 / x,
        gamma: x => -1 / x,
        binomial: x => 1 / (1 + Math.exp(x))
    }[family];

    return values
        .map((val, i) => [-1, 1].map(sign => invLink(val + sign * statValue * stdErr[i])).sort())
};
github TwoRavens / TwoRavens / assets / app / solvers / wrapped.js View on Github external
let makeIntervals = ({values, variances, statistic, type, family, alpha, n, ddof, MSE, m}) => {

    // MSE is already included in the coefficient variance-covariance matrix
    let stdErr = variances.map({
        mean: _ => _,
        prediction: x => (MSE * 1 / (m || 1)) + x,
    }[type]).map(Math.sqrt);

    let g = values.length;

    let statValue = {
        // simultaneous region over regression surface
        workingHotelling: Math.sqrt(ddof * jStat.centralF.inv(1 - alpha, ddof, n - ddof)),

        // simultaneous set
        scheffe: Math.sqrt(g * jStat.centralF.inv(1 - alpha, g, n - ddof)),
        bonferroni: jStat.studentt.inv(1 - alpha / (2 * g), n - ddof),

        // pointwise
        t: jStat.studentt.inv(1 - alpha / 2, n - ddof)
    }[statistic];

    let invLink = {
        gaussian: _ => _,
        poisson: x => Math.exp(x),
        exponential: x => -1 / x,
        gamma: x => -1 / x,
        binomial: x => 1 / (1 + Math.exp(x))
    }[family];
github TwoRavens / TwoRavens / assets / app / solvers / wrapped.js View on Github external
let makeIntervals = ({values, variances, statistic, type, family, alpha, n, ddof, MSE, m}) => {

    // MSE is already included in the coefficient variance-covariance matrix
    let stdErr = variances.map({
        mean: _ => _,
        prediction: x => (MSE * 1 / (m || 1)) + x,
    }[type]).map(Math.sqrt);

    let g = values.length;

    let statValue = {
        // simultaneous region over regression surface
        workingHotelling: Math.sqrt(ddof * jStat.centralF.inv(1 - alpha, ddof, n - ddof)),

        // simultaneous set
        scheffe: Math.sqrt(g * jStat.centralF.inv(1 - alpha, g, n - ddof)),
        bonferroni: jStat.studentt.inv(1 - alpha / (2 * g), n - ddof),

        // pointwise
        t: jStat.studentt.inv(1 - alpha / 2, n - ddof)
    }[statistic];

    let invLink = {
        gaussian: _ => _,
        poisson: x => Math.exp(x),
        exponential: x => -1 / x,
        gamma: x => -1 / x,
        binomial: x => 1 / (1 + Math.exp(x))
    }[family];

    return values
        .map((val, i) => [-1, 1].map(sign => invLink(val + sign * statValue * stdErr[i])).sort())
github zhilu-nanjing / financial-cell / src / calc / expression_fn / lib / statistical.js View on Github external
exports.NORM.DIST = function(x, mean, sd, cumulative) {
  cumulative = parseBool(cumulative)
  x = parseNumber(x);
  mean = parseNumber(mean);
  sd = parseNumber(sd);
  if (anyIsError(x, mean, sd)) {
    return Error(ERROR_VALUE);
  }
  if (sd <= 0) {
    return Error(ERROR_NUM);
  }

  // Return normal distribution computed by jStat [http://jstat.org]
  return (cumulative) ? jStat.normal.cdf(x, mean, sd) : jStat.normal.pdf(x, mean, sd);
};
github getguesstimate / guesstimate-app / src / lib / guesstimator / samplers / simulator-worker / simulator / distributions / distributions.js View on Github external
return max - (max - mode)*Math.sqrt(2*(1-u))
  }
}

// Source:
// https://en.wikipedia.org/wiki/Beta_distribution#Transformations
function PERT(min, max, mode = (min + max)/2, lambda = 4) {
  const width = max - min
  const a = 1 + lambda * ((mode - min)/width)
  const b = 1 + lambda * ((max - mode)/width)
  const p = jStat.beta.sample(a, b)
  return min + p*width
}

export const Distributions = {
  beta: jStat.beta.sample,
  centralF: jStat.centralF.sample,
  cauchy: jStat.cauchy.sample,
  chisquare: jStat.chisquare.sample,
  exponential: jStat.exponential.sample,
  invgamma: jStat.invgamma.sample,
  lognormal: jStat.lognormal.sample,
  normal: jStat.normal.sample,
  studentt: jStat.studentt.sample,
  weibull: jStat.weibull.sample,
  uniform: jStat.uniform.sample,
  gamma: jStat.gamma.sample,
  triangular,
  doubleTriangular,
  PERT,
  bernoulli: bernoulli,
  if: bernoulli,
github getguesstimate / guesstimate-app / src / lib / guesstimator / samplers / simulator-worker / simulator / distributions / distributions.js View on Github external
// Source:
// https://en.wikipedia.org/wiki/Beta_distribution#Transformations
function PERT(min, max, mode = (min + max)/2, lambda = 4) {
  const width = max - min
  const a = 1 + lambda * ((mode - min)/width)
  const b = 1 + lambda * ((max - mode)/width)
  const p = jStat.beta.sample(a, b)
  return min + p*width
}

export const Distributions = {
  beta: jStat.beta.sample,
  centralF: jStat.centralF.sample,
  cauchy: jStat.cauchy.sample,
  chisquare: jStat.chisquare.sample,
  exponential: jStat.exponential.sample,
  invgamma: jStat.invgamma.sample,
  lognormal: jStat.lognormal.sample,
  normal: jStat.normal.sample,
  studentt: jStat.studentt.sample,
  weibull: jStat.weibull.sample,
  uniform: jStat.uniform.sample,
  gamma: jStat.gamma.sample,
  triangular,
  doubleTriangular,
  PERT,
  bernoulli: bernoulli,
  if: bernoulli,
  test: bernoulli,
  binomial: binomial,
  poisson: poisson,
  negBinomial: negBinomial
github getguesstimate / guesstimate-app / src / lib / guesstimator / samplers / simulator-worker / simulator / distributions / distributions.js View on Github external
}

// Source:
// https://en.wikipedia.org/wiki/Beta_distribution#Transformations
function PERT(min, max, mode = (min + max)/2, lambda = 4) {
  const width = max - min
  const a = 1 + lambda * ((mode - min)/width)
  const b = 1 + lambda * ((max - mode)/width)
  const p = jStat.beta.sample(a, b)
  return min + p*width
}

export const Distributions = {
  beta: jStat.beta.sample,
  centralF: jStat.centralF.sample,
  cauchy: jStat.cauchy.sample,
  chisquare: jStat.chisquare.sample,
  exponential: jStat.exponential.sample,
  invgamma: jStat.invgamma.sample,
  lognormal: jStat.lognormal.sample,
  normal: jStat.normal.sample,
  studentt: jStat.studentt.sample,
  weibull: jStat.weibull.sample,
  uniform: jStat.uniform.sample,
  gamma: jStat.gamma.sample,
  triangular,
  doubleTriangular,
  PERT,
  bernoulli: bernoulli,
  if: bernoulli,
  test: bernoulli,
  binomial: binomial,