index.js
function LDA(...classes) {
	// Compute pairwise LDA classes (needed for multiclass LDA)
	if(classes.length < 2) {
		throw new Error('Please pass at least 2 classes');
	}

	let numberOfPairs = classes.length * (classes.length - 1) / 2;
	let pair1 = 0;
	let pair2 = 1;

	let pairs = new Array(numberOfPairs);

	for(let i = 0; i < numberOfPairs; i++){
		pairs[i] = computeLdaParams(classes[pair1], classes[pair2], pair1, pair2);

		pair2++;
		if(pair2 == classes.length) {
			pair1++;
			pair2 = pair1 + 1;
		}
	} 

	this.pairs = pairs;
	this.numberOfClasses = classes.length;
}
function LDA(...classes) {
	// Compute pairwise LDA classes (needed for multiclass LDA)
	if(classes.length < 2) {
		throw new Error('Please pass at least 2 classes');
	}

	let numberOfPairs = classes.length * (classes.length - 1) / 2;
	let pair1 = 0;
	let pair2 = 1;

	let pairs = new Array(numberOfPairs);

	for(let i = 0; i < numberOfPairs; i++){
		pairs[i] = computeLdaParams(classes[pair1], classes[pair2], pair1, pair2);

		pair2++;
		if(pair2 == classes.length) {
			pair1++;
			pair2 = pair1 + 1;
		}
	} 

	this.pairs = pairs;
	this.numberOfClasses = classes.length;
}
function LDA ( ... classes ) { // Compute pairwise LDA classes (needed for multiclass LDA) if ( classes . length < 2 ) { throw new Error ( 'Please pass at least 2 classes' ) ; } let numberOfPairs = classes . length * ( classes . length - 1 ) / 2 ; let pair1 = 0 ; let pair2 = 1 ; let pairs = new Array ( numberOfPairs ) ; for ( let i = 0 ; i < numberOfPairs ; i ++ ) { pairs [ i ] = computeLdaParams ( classes [ pair1 ] , classes [ pair2 ] , pair1 , pair2 ) ; pair2 ++ ; if ( pair2 == classes . length ) { pair1 ++ ; pair2 = pair1 + 1 ; } } this . pairs = pairs ; this . numberOfClasses = classes . length ; }
An LDA object.
@constructor
@param {...number[][]} classes - Each parameter is a 2d class array. In each class array, rows are samples, columns are variables.
@example
let classifier = new LDA(class1, class2, class3);
An LDA object .