GithubHelp home page GithubHelp logo

mrredbeard / numbers.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from numbers/numbers.js

0.0 2.0 0.0 864 KB

Advanced Mathematics Library ready for standard JavaScript use forked from https://github.com/numbers/numbers.js

License: Apache License 2.0

JavaScript 100.00%
javascript math mathem numbers calculus dsp fft matrix prime

numbers.js's Introduction

numbers.js Forked from http://github.com/sjkaliski/numbers.js compiled/bundled ready for use

Numbers - an advanced mathematics toolkit for JavaScript.

Changed just enough of the original library to get it to work in html out of the box ES5 compliant.

Description

Numbers provides a comprehensive set of mathematical tools that currently are not offered in JavaScript. These tools include:

  • Basic calculations
  • Calculus
  • Matrix Operations
  • Prime Numbers
  • Statistics
  • More...

A few things to note before using: JavaScript, like many languages, does not necessarily manage floating points as well as we'd all like it to. For example, if adding decimals, the addition tool won't return the exact value. This is an unfortunate error. Precautions have been made to account for this. After including numbers, you can set an error bound. Anything in this will be considered an "acceptable outcome."

The primary uses cases are client side operations which the DOM will recognize (e.g. 1.1px == 1px). It can be used for data analysis, calculations, etc. on the server as well.

How to use

Numbers is pretty straightforward to use.

See example

For example, if we wanted to estimate the integral of sin(x) from -2 to 4, we could:

Use Riemann integrals (with 200 subdivisions)

numbers.calculus.Riemann(Math.sin, -2, 4, 200);

Or use adaptive simpson quadrature (with epsilon .0001)

numbers.calculus.adaptiveSimpson(Math.sin, -2, 4, .0001);

User-defined functions can be used too:

var myFunc = function(x) {
  return 2*Math.pow(x,2) + 1;
}

numbers.calculus.Riemann(myFunc, -2, 4, 200);
numbers.calculus.adaptiveSimpson(myFunc, -2, 4, .0001);

Now say we wanted to run some matrix calculations:

We can add two matrices

var array1 = [0, 1, 2];
var array2 = [3, 4, 5];

numbers.matrix.addition(array1, array2);

We can transpose a matrix

numbers.matrix.transpose(array);

When working with vectors, treat them like single row matrices:

var vector1 = [[1, 0, 0]];

Numbers also includes some basic prime number analysis. We can check if a number is prime:

// basic check
numbers.prime.simple(number);

// Miller-Rabin primality test
numbers.prime.millerRabin(number);

The statistics tools include mean, median, mode, standard deviation, random sample generator, correlation, confidence intervals, t-test, chi-square, and more.

numbers.statistic.mean(array);
numbers.statistic.median(array);
numbers.statistic.mode(array);
numbers.statistic.standardDev(array);
numbers.statistic.randomSample(lower, upper, n);
numbers.statistic.correlation(array1, array2);

For further documentation, check out numbers.github.io

Core Team

Contributors

In no particular order:

numbers.js's People

Contributors

sjkaliski avatar dakkers avatar ethanresnick avatar kartiktalwar avatar mattfowler avatar milroc avatar larrybattle avatar mrredbeard avatar napoleond avatar devanp92 avatar zikes avatar philipithomas avatar foundrium avatar mjhasbach avatar btmills avatar bring2dip avatar bitdeli-chef avatar thebyrd avatar gillescastel avatar leppert avatar hrishikeshparanjape avatar jedborovik avatar jdan avatar nkohari avatar him2him2 avatar timrwood avatar swairshah avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.