How to use the mathjs.max function in mathjs

To help you get started, we’ve selected a few mathjs 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 ClimbsRocks / ensembler / utils.js View on Github external
if( global.argv.fileNames.problemType === 'multi-category' ) {
        var allResults = module.exports.multiclassFeatureEngineering( row, classesToIndexMap, indexToClassesMap);
        
        var bestPredictions = global.ensembleNamespace.acceptablePredictions[i];
        var bestResults = module.exports.multiclassFeatureEngineering( bestPredictions, classesToIndexMap, indexToClassesMap);

        // var aggregatedRow = row.concat(allResults, bestResults);
        var aggregatedRow = allResults.concat(bestResults);

        global.ensembleNamespace.dataMatrix[i] = aggregatedRow;


      } else {
        row.push( math.mean(row) );
        row.push( math.median(row) );
        row.push( math.max(row) );
        row.push( math.min(row) );

        row.push( math.max(row) - math.min(row) ); // this is the total range of predictions

        row.push( math.sum(row) );
        row.push( math.var(row) ); //this is the variance

        // calculate the consensus vote, as well as what percent of classifiers had that vote. 
        // console.log('global.argv');
        // console.log(global.argv)
        if( global.argv.fileNames.problemType === 'category') {
          // TODO: generalize this to work with multi-category predictions
          var roundedRow = [];
          var voteCount = {
            0 : 0,
            1 : 0
github bjoernkarmann / project_alias / server / js / sound.js View on Github external
stream.on('data', buffer => {
      if(config.debug) console.time("bufferTime");
      buffers.push(buffer); // -> save previous recorded data
      var headerBuf = header(config.rate, config); // ->  create wav header
      buffers.unshift(headerBuf); // -> set header in top of buffers
      var length = math.sum(buffers.map(b => b.length));
      try{
        var result = wav.decode(Buffer.concat(buffers, length)) // -> decode buffers to float array
        var wave = result.channelData[0];
        var slice = wave.slice(0,size);
        var fftValues = makeFFT(slice);
        callback(fftValues);
        if(config.debug) {
          console.timeEnd("bufferTime");
          console.log("Max: "+math.max(fftValues));
        }
      }catch(err){
        console.error(err);
      }
      buffers = []; // free recorded data
    });
    micInstance.start();
github firepick1 / firenodejs / js / lib / LPPCurve.js View on Github external
var maxp2 = 0;
        var maxp3 = 0;
        for (var i = 0; i < pts.length; i++) {
            var pt = pts[i];
            logger.debug(i,
                "\t", pt.p1 - ptPrev.p1,
                "\t", pt.p1,
                "\t", pt.p2,
                "\t", pt.p3,
                "\t", pt.x,
                "\t", pt.y,
                "\t", pt.z
            );
            maxp1 = math.max(maxp1, math.abs(pt.p1 - ptPrev.p1));
            maxp2 = math.max(maxp2, math.abs(pt.p2 - ptPrev.p2));
            maxp3 = math.max(maxp3, math.abs(pt.p3 - ptPrev.p3));
            ptPrev = pt;
            if (pt.z > lpp.zHigh - lpp.zVertical) {
                math.abs(pt.x).should.below(0.1);
                math.abs(pt.y).should.below(0.1);
            }
            if (z + lpp.zVertical > pt.z) {
                math.abs(x - pt.x).should.below(0.1);
                math.abs(y - pt.y).should.below(0.1);
            }
        }
        var cmd = new DVSFactory().createDVS(pts);
        logger.debug(JSON.stringify(cmd));
    });
    it("ph5Path(x,y,z) path should accelerate smoothly ", function() {
github soswow / Various-JS-and-Python / JS / evolution-strategies / nes.js View on Github external
const renderMatrix = (matrix) => {
    const imageData = context2.createImageData(W, H);
    const totalMax = Math.max(math.max(matrix), Math.abs(math.min(matrix)));
    math.forEach(matrix, (el, [y, x]) => {
        const r = 0;
        let g = b = 0;
        if (el > 0) {
            g = 255;
        } else {
            b = 255;
        }
        setPixelInImageData(imageData, x, y, r, g, b, Math.abs(el) / totalMax * 255);
    });
    context2.putImageData(imageData, 0, 0);
}
github devalpha-io / devalpha-node / lib / reducers / util.js View on Github external
export function buildMaxDrawdown(state) {
  const totals = state.get('history').map(h => h.get('total')).toArray()
  const maxReturn = b(math.max(totals))
  const drawdowns = totals.map(t => chain(t).subtract(maxReturn).divide(maxReturn).done())
  return n(math.min(drawdowns))
}
github Zooz / predator / src / reports / models / finalReportGenerator.js View on Github external
result.errors[error] += count;
            } else {
                result.errors[error] = count;
            }
        });

        result.rps.count += stats.rps.count;
        result.requestsCompleted += stats.requestsCompleted;

        result.pendingRequests += stats.pendingRequests;
    });

    result.rps.mean = result.rps.count / STATS_INTERVAL;
    result.latency.median = math.median(medians);
    result.latency.min = math.min(mins);
    result.latency.max = math.max(maxs);
    result.latency.p95 = math.sum(request95) / result.requestsCompleted;
    result.latency.p99 = math.sum(request99) / result.requestsCompleted;

    result.scenarioDuration.p95 = math.sum(scenario95) / result.scenariosCompleted;
    result.scenarioDuration.p99 = math.sum(scenario99) / result.scenariosCompleted;

    return result;
}
github Zooz / predator / src / reports / models / aggregateReportGenerator.js View on Github external
result.errors[error] += count;
            } else {
                result.errors[error] = count;
            }
        });
    });

    result.latency.median = math.median(requestMedians);
    result.latency.min = math.min(requestMins);
    result.latency.max = math.max(requestMaxs);
    result.latency.p95 = math.sum(request95) / result.requestsCompleted;
    result.latency.p99 = math.sum(request99) / result.requestsCompleted;

    result.scenarioDuration.median = math.median(scenarioMedians);
    result.scenarioDuration.min = math.min(scenarioMins);
    result.scenarioDuration.max = math.max(scenarioMaxs);
    result.scenarioDuration.p95 = math.sum(scenario95) / result.scenariosCompleted;
    result.scenarioDuration.p99 = math.sum(scenario99) / result.scenariosCompleted;

    return result;
}
github Bluegrass-Grief-Owls / coordin-eat / server / midpointAlgorithm / mockGetTravelTime.js View on Github external
const maxDistanceFromCentroid = (centroid, origins) => {
	const dists = origins.map(coord => math.distance(coord, centroid))
	return math.max(dists)
}

mathjs

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif

Apache-2.0
Latest version published 21 days ago

Package Health Score

89 / 100
Full package analysis