Skip to content

Repository files navigation

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

varv=newVector(100).fillBy(()=>Math.random());var{x,y,dx}=v.histogram({bins: 10});varmode=x[y.argmax()];console.log('Most values between:',mode,mode+dx);vary_cum=y.cumsum();console.log('Cumulative distribution:',x,y_cum);varlessCount=v.lessThan(0.5).sum();console.log('Smaller than 0.5:',lessCount/v.length);// vector operations:varv=Vector.from([0,3,2,12,3]);varsize=v.magnitude();varresult=v.add(1).subtract([1,3,-2,2,7]).dot([5,0,1,-3,4]);

Licensing

MIT License

About

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

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages