How to use the jstat.variance 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 zhilu-nanjing / financial-cell / test / mycode / myfunc.js View on Github external
export function FTEST(array1, array2) {
    if (!array1 || !array2) {
        return errorObj.ERROR_NA;
    }
    if (!(array1 instanceof Array) || !(array2 instanceof Array)) {
        return errorObj.ERROR_NA;
    }
    if (array1.length < 2 || array2.length < 2) {
        return errorObj.ERROR_DIV0;
    }
    let sum1 = jStat.variance(array1);
    let sum2 = jStat.variance(array2);
    if(sum1 >= sum2){
        return 2*jStat.ftest(sum1/sum2,array1.length - 1,array2.length - 1);
    }
    if(sum2 > sum1){
        return 2*jStat.ftest(sum2/sum1,array2.length - 1,array1.length - 1);
    }

};
github zhilu-nanjing / financial-cell / test / mycode / myfunc.js View on Github external
export function FTEST(array1, array2) {
    if (!array1 || !array2) {
        return errorObj.ERROR_NA;
    }
    if (!(array1 instanceof Array) || !(array2 instanceof Array)) {
        return errorObj.ERROR_NA;
    }
    if (array1.length < 2 || array2.length < 2) {
        return errorObj.ERROR_DIV0;
    }
    let sum1 = jStat.variance(array1);
    let sum2 = jStat.variance(array2);
    if(sum1 >= sum2){
        return 2*jStat.ftest(sum1/sum2,array1.length - 1,array2.length - 1);
    }
    if(sum2 > sum1){
        return 2*jStat.ftest(sum2/sum1,array2.length - 1,array1.length - 1);
    }

};
github zhilu-nanjing / financial-cell / src / calc / expression_fn / lib / statistical.js View on Github external
exports.F.TEST = function (array1, array2) {
  if (!array1 || !array2) {
    return Error(ERROR_NA);
  }
  if (!(array1 instanceof Array) || !(array2 instanceof Array)) {
    return Error(ERROR_NA);
  }
  if (array1.length < 2 || array2.length < 2) {
    return Error(ERROR_DIV0);
  }
  let sum1 = jStat.variance(array1);
  let sum2 = jStat.variance(array2);
  if (sum1 >= sum2) {
    return 2 * jStat.ftest(sum1 / sum2, array1.length - 1, array2.length - 1);
  }
  if (sum2 > sum1) {
    return 2 * jStat.ftest(sum2 / sum1, array2.length - 1, array1.length - 1);
  }

};
github zhilu-nanjing / financial-cell / src / calc / expression_fn / lib / statistical.js View on Github external
exports.F.TEST = function (array1, array2) {
  if (!array1 || !array2) {
    return Error(ERROR_NA);
  }
  if (!(array1 instanceof Array) || !(array2 instanceof Array)) {
    return Error(ERROR_NA);
  }
  if (array1.length < 2 || array2.length < 2) {
    return Error(ERROR_DIV0);
  }
  let sum1 = jStat.variance(array1);
  let sum2 = jStat.variance(array2);
  if (sum1 >= sum2) {
    return 2 * jStat.ftest(sum1 / sum2, array1.length - 1, array2.length - 1);
  }
  if (sum2 > sum1) {
    return 2 * jStat.ftest(sum2 / sum1, array2.length - 1, array1.length - 1);
  }

};