UNPKG

pw-csp

Version:
99 lines (60 loc) 2.51 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Home - Documentation</title> <script src="scripts/prettify/prettify.js"></script> <script src="scripts/prettify/lang-css.js"></script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/ionicons.min.css"> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="CSP.html">CSP</a><ul class='methods'><li data-type='method'><a href="CSP.html#project">project</a></li></ul></li></ul> </nav> <div id="main"> <section class="readme"> <article><h1>pw-csp</h1><p>Common spatial pattern in JavaScript</p> <h2>Installation</h2><pre class="prettyprint source lang-bash"><code>npm install pw-csp</code></pre><h2>Getting Started</h2><p>CSP projects classes of data points so that one has high variance in one axis, and the other has high variance in the other axis.</p> <p>The example below is two-dimensional, but any number of dimensions may be used. The csp.project function accepts an array of data points, projects them using CSP, and returns the requested number of dimensions, sorted by descending importance. Each array should be of size <em>number of samples</em> rows x <em>number of signals</em> columns.</p> <pre class="prettyprint source lang-javascript"><code>var CSP = require('pw-csp'); var a = [ [-1, -1], [1, 1] ]; var b = [ [-1, 1], [1, -1] ]; var csp = new CSP(a, b); var ap = csp.project(a, 2); var bp = csp.project(b, 2); console.log(ap); /* [ [ 1.414, 0 ], [ -1.414, 0 ] ] */ console.log(bp); /* [ [ 0, -1.414 ], [ 0, 1.414 ] ] */</code></pre></article> </section> </div> <br class="clear"> <footer> Documentation generated at Thu Nov 16 2017 22:31:54 GMT-0600 (Central Standard Time) </footer> <script>prettyPrint();</script> <script src="scripts/linenumber.js"></script> </body> </html>