Socket
Socket
Sign inDemoInstall

ts-vector

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ts-vector

A vector and numeric array implementation with common math and statistical functions for JavaScript and TypeScript


Version published
Weekly downloads
4
increased by100%
Maintainers
1
Install size
535 kB
Created
Weekly downloads
 

Readme

Source

ts-vector

ts-vector provides a Vector class that extends the JavaScript/TypeScript array with the most commonly used mathematical and statistical functions.

This library uses EcmaScript 6 array inheritance, so it's not going to work in old browsers!
Node.js 5.0 and the latest Chrome already support most of the Array inheritance features.

Install it from NPM: npm install ts-vector , or use a bundled .js file: ts-vector.js

Check the API Reference

Examples

var v = new Vector(100).fillBy(() => Math.random());
var {x,y,dx} = v.histogram({ bins: 10 }); 
var mode = x[y.argmax()];
console.log('Most values between:', mode, mode + dx);
var y_cum = y.cumsum();
console.log('Cumulative distribution:', x, y_cum);

var lessCount = v.lessThan(0.5).sum();
console.log('Smaller than 0.5:', lessCount/v.length);

// vector operations:

var v = Vector.from([0, 3, 2, 12, 3]);
var size = v.magnitude();
var result = v.add(1).subtract([1, 3, -2, 2, 7]).dot([5, 0, 1, -3, 4]);
Licensing

MIT License

Keywords

FAQs

Last updated on 09 Jul 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc