How to use the jstat.studentt function in jstat

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 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 zhilu-nanjing / financial-cell / src / calc / expression_fn / lib / statistical.js View on Github external
exports.T.INV['2T'] = function(probability, df) {
  probability = parseNumber(probability);
  df = parseNumber(df);
  if (probability <= 0 || probability > 1 || df < 1) {
    return Error(ERROR_NUM);
  }
  if (anyIsError(probability, df)) {
    return Error(ERROR_VALUE);
  }
  return Math.abs(jStat.studentt.inv(probability/2, df));
};
github zhilu-nanjing / financial-cell / src / calc / expression_fn / lib / statistical.js View on Github external
exports.T.DIST = function (x, df, cumulative) {
  cumulative = parseBool(cumulative)
  x = parseNumber(x);
  df = parseNumber(df);
  if (anyIsError(x, df)) {
    return Error(ERROR_VALUE);
  }
  return (cumulative) ? jStat.studentt.cdf(x, df) : jStat.studentt.pdf(x, df);
};
github zhilu-nanjing / financial-cell / src / calc / expression_fn / lib / statistical.js View on Github external
exports.T.DIST.RT = function(x, df) {
  if (arguments.length !== 2) {
    return Error(ERROR_NA);
  }

  if (x < 0 || df < 1) {
    return Error(ERROR_NUM);
  }

  if ((typeof x !== 'number') || (typeof df !== 'number')) {
    return Error(ERROR_VALUE);
  }

  return 1 - jStat.studentt.cdf(x , df);
};