jStat Documentation


Table Of Contents


Overview

Description

jStat is a statistical library written in JavaScript that allows you to perform advanced statistical operations without the need of a dedicated statistical language (e.g. MATLAB or R).

Architecture

Calculations are done by static methods, while working with groups of numbers is handled by the instance methods. Here is a pseudo example of what is happening in core.js:

jStat.min = function( arr ) {
    return Math.min.apply( null, arr );
}

jStat.prototype.min = function() {
    var i = 0,
        newval = [];
    while( newval.push( jStat.min( this[i] )), ++i < this.length );
    return newval;
}

jStat.min does the actual calculation on the array, while jStat.prototype.min is a wrapper to help work with the jStat object. The reason for this approach is to allow for maxium flexibility to other developers who want to extend jStat, while allowing for easy creation of wrappers. This way extending jStat requires minimal performance overhead and allows for more unique wrappers to be created.

Remember: Static methods almost always return native JavaScript types. Instance methods always return a jStat object.

Here is a simple example on the difference in usage between the static and instance methods:

var myVect = [2,6,4,7,2,7,4],
    jObj = jStat( myVect );

// calculate the sum of the the vector
jStat.sum( myVect ) === 32;
jObj.sum() === 32;

Now say we want to do several operations on the vector (e.g. sum, min, max, and standard deviation). This can be accomplished using the static methods, but each will need to be called separately. By using the jStat object we can pass callback functions and chain the execution of each operation:

jObj.sum( function( val ) {
    // val === sum
}).min( function( val ) {
    // val === min
}).max( function( val ) {
    // val === max
}).stdev( function( val ) {
    // val === st. dev.
});

This method sets each calculation to be executed in an asynchronous queue. Very useful method of preventing blocking when working with large data sets.

Let's look at a few chaining and shorthand examples:

jStat( 0, 1, 11 ) === jStat( jStat.seq( 0, 1, 11 ));
jStat().rand( 4, 4 ) === jStat( jStat.rand( 4, 4 ));

jStat().create( 5, function( x, y ) {
    return ( x + Math.random()) / ( y + Math.random());
}).min( true, function( x ) {
    // do something with the min value
}).beta( 0.5, 0.5 ).pdf();  // generate and return the pdf
                            // of the beta function for all values

Core Functionality

Core functionality include methods that generate and analyse vectors or matrices.

jStat()

The jStat object can function in several capacities, as demonstrated below. In all cases, jStat will always return an instance of itself.

jStat( array[, fn] )

Create a new jStat object from either an existing array or jStat object. For example, create a new jStat matrix by doing the following:

var matrix = jStat([[ 1, 2, 3 ],[ 4, 5, 6 ],[ 7, 8, 9 ]]);

If an existing jStat object is passed as an argument then it will be cloned into a new object:

var stat1 = jStat([[ 1, 2 ],[ 3, 4 ]]),
    stat2 = jStat( stat1 );

To transform the data on creation, pass a function as the final argument:

jStat([[ 1, 2 ],[ 3, 4 ]], function( x ) {
    return x * 2;
});

jStat( start, stop, count[, fn ])

To create a sequence then pass numeric values in the same form jStat.seq() would be used:

var vector = jStat( 0, 1, 5 );
// vector === [[ 0, 0.25, 0.5, 0.75, 1 ]]

By passing a function the sequence value can be manipulated:

var vector = jStat( 0, 1, 5, function( x ) {
    return x * 2;
});
// vector === [[ 0, 0.5, 1, 1.5, 2 ]];

The second argument passed to the function is the count (starting from 0). Using this we can create a multidimensional array (useful for plotting data):

var betaGraph = jStat( 0, 1, 11, function( x, cnt ) {
    return [ jStat.beta.pdf( x, alpha, beta ), cnt ];
});

jStat()

A chainable shortcut in the API exists to allow for filling in the data after object creation. So creating jStat objects from methods like rand() can be accomplished in one of the following ways:

// pass the generated random 3x3 matrix to jStat
jStat( jStat.rand( 3 ));
// or create an empty instance that is filled in afterwards
jStat().rand( 3 );

rows()

Returns the count of rows in a matrix.

rows( array )

var matrix = [[1,2,3],[4,5,6]];
jStat.rows( matrix ) === 2;

fn.rows( [callback] )

jStat( matrix ).rows() === 2;

Or pass a callback to run the calculation asynchronously and pass on the calculation. This allows for continued chaining of methods to the jStat object. Also note this within the callback refers to the calling jStat object.

jStat( matrix ).rows(function( d ) {
    // d === 2
});

cols()

Returns the number of columns in a matrix.

cols( array )

var matrix = [[1,2,3],[4,5,6]];
jStat.cols( matrix ) === 3;

fn.cols( [callback] )

jStat( matrix ).cols() === 3;

Or pass a callback to run the calculation asynchronously and pass on the calculation. This allows for continued chaining of methods to the jStat object. Also note this within the callback refers to the calling jStat object.

jStat( matrix ).cols(function( d ) {
    // d === 3
});

dimensions()

Returns and object with the dimensions of a matrix.

dimensions( array )

var matrix = [[1,2,3],[4,5,6]];
jStat.dimensions( matrix ) === { cols: 3, rows: 2 };

fn.dimensions( [callback] )

jStat( matrix ).dimensions() === { cols: 3, rows: 2 };

Or pass a callback to run the calculation asynchronously and pass on the calculation. This allows for continued chaining of methods to the jStat object. Also note this within the callback refers to the calling jStat object.

jStat( matrix ).dimensions(function( d ) {
    // d === { cols: 3, rows: 2 }
});

row()

Returns a specified row of a matrix.

row( array, index )

var matrix = [[1,2,3],[4,5,6]];
jStat.row( matrix, 0 ) === [1,2,3];

fn.row( index[, callback] )

jStat( matrix ).row( 0 ) === jStat([1,2,3]);

Or pass a callback to run the calculation asynchronously and pass on the calculation. This allows for continued chaining of methods to the jStat object. Also note this within the callback refers to the calling jStat object.

jStat( matrix ).row( 0, function( d ) {
    // d === jStat([1,2,3])
});

col()

Returns the specified column as a column vector.

col( index )

var matrix = [[1,2],[3,4]];
jStat.col( matrix, 0 ) === [[1],[3]];

fn.col( index[, callback] )

jStat( matrix ).col( 0 ) === jStat([[1],[3]]);

Or pass a callback to run the calculation asynchronously and pass on the calculation. This allows for continued chaining of methods to the jStat object. Also note this within the callback refers to the calling jStat object.

jStat( matrix ).col( 0, function( d ) {
    // d === jStat([[1],[3]])
})

diag()

Returns the diagonal of a matrix.

diag( array )

var matrix = [[1,2,3],[4,5,6],[7,8,9]];
jStat.diag( matrix ) === [[1],[5],[9]];

fn.diag( [callback] )

jStat( matrix ).diag() === jStat([[1],[5],[9]]);

Or pass a callback to run the calculation asynchronously and pass on the calculation. This allows for continued chaining of methods to the jStat object. Also note this within the callback refers to the calling jStat object.

jStat( matrix ).diag(function( d ) {
    // d === jStat([[1],[5],[9]])
});

antidiag()

Returns the anti-diagonal of the matrix.

antidiag( array )

var matrix = [[1,2,3],[4,5,6],[7,8,9]];
jStat.antidiag( matrix ) === [[3],[5],[7]];

fn.antidiag( [callback] )

jStat( matrix ).antidiag() === jStat([[3],[5],[7]]);

Or pass a callback to run the calculation asynchronously and pass on the calculation. This allows for continued chaining of methods to the jStat object. Also note this within the callback refers to the calling jStat object.

jStat( matrix ).antidiag(function( d ) {
    // d === jStat([[3],[5],[7]])
});

transpose()

Transpose a matrix.

transpose( array )

var matrix = [[1,2],[3,4]];
jStat.transpose( matrix ) === [[1,3],[2,4]];

fn.transpose( [callback] )

jStat( matrix ).transpose() === [[1,3],[2,4]];

Or pass a callback to run the calculation asynchronously and pass on the calculation. This allows for continued chaining of methods to the jStat object. Also note this within the callback refers to the calling jStat object.

jStat( matrix ).transpose(function( d ) {
    // d === jStat([[1,3],[2,4]])
})

map( func )

Map a function to all values and return a new object.

map( array, fn )

var matrix = [[1,2],[3,4]];
jStat.map( matrix, function( x ) {
    return x * 2;
});
// returns [[2,4],[6,8]]

fn.map( fn )

jStat( matrix ).map(function( x ) {
    return x * 2;
});

alter( func )

Destructively map to an array.

alter( array, fn )

var matrix = [[1,2],[3,4]];
jStat.alter( matrix, function( x ) {
    return x * 2;
});
// matrix === [[2,4],[6,8]]

fn.alter( fn )

var matrix = [[1,2],[3,4]];
jStat( matrix ).alter( function( x ) {
    return x * 2;
});

create()

Create a row by col matrix using the supplied function If col is omitted then it will default to value row.

create( row[, col], fn )

jStat.create( 2, function( row, col ) {
    return row + col;
});
// returns [[0,1],[1,2]]

fn.create( row[, col], fn )

Use this technique for creating matrices in jStat instances.

jStat().create( 2, function( row, col ) {
    return row + col;
});
// returns jStat([[0,1],[1,2]])

zeros()

Create a row by col matrix of all zeros. If col is omitted then it will default to value row.

zeros( row[, col] )

jStat.zeros( 2 );
// returns [[0,0],[0,0]]

fn.zeros( row[, col] )

Use this technique for creating matrices in jStat instances.

jStat().zeros( 2 );
// returns jStat([[0,0],[0,0]])

ones()

Create a row by col matrix of all ones. If col is omitted then it will default to value row.

ones( row[, col] )

jStat.zeros( 2 );
// returns [[0,0],[0,0]]

fn.ones( row[, col] )

Use this technique for creating matrices in jStat instances.

jStat().ones( 2 );
// returns jStat([[0,0],[0,0]])

rand()

Create a matrix of normally distributed random numbers. If col is omitted then it will default to value row.

rand( row[, col] )

jStat.rand( 3 );

fn.rand( row[, col] )

Use this technique for creating matrices in jStat instances.

jStat().rand( 3 );

identity()

Create an identity matrix of row by col. If col is omitted then it will default to value row.

identity( row[, col] )

jStat.identity( 2 );
// returns [[1,0],[0,1]]

fn.identity( row[, col] )

Use this technique for creating matrices in jStat instances.

jStat().identity( 2 );

clear()

Set all values in the vector or matrix to zero.

clear( array )

var tmp = [1,2,3];
jStat.clear( tmp );
// tmp === [0,0,0]

fn.clear( [callback] )

jStat( 0, 1, 3 ).clear();
// returns [[0,0,0]]

If a callback is passed then the original object is not altered

var obj = jStat( 0, 1, 3 );
obj.clear(function() {
    // this === [ 0, 0, 0 ]
});
// obj === [ 0, 0.5, 1 ]

symmetric()

Tests if a matrix is symmetric.

symmetric( array )

jStat.symmetric([[1,2],[2,1]]) === true

fn.symmetric( callback )

jStat([[1,2],[2,1]]).symmetric() === true

Can pass a callback to maintain chainability

jStat([[1,2],[2,1]]).symmetric(function( result ) {
    // result === true
});

jStat Utility Methods

Utilities that are used throughout the jStat library

utils.calcRdx( num0, num1 )

Calculate the decimal shift for the IEEE 754 floating point calculation correction.

utils.isArray( arg )

Test if arg is an array.

utils.isFunction( arg )

Test if arg is a function.

utils.isNumber( arg )

Test if arg is a number and not NaN.

Vector Functionality

sum()

sum( array )

Return the sum of a vector.

jStat.sum([1,2,3]) === 6

fn.sum( [bool][,callback] )

Return the sum of a vector or matrix columns.

jStat( 1, 5, 5 ).sum() === 15
jStat([[1,2],[3,4]]).sum() === [ 4, 6 ]

If callback is passed then will pass result as first argument.

jStat( 1, 5, 5 ).sum(function( result ) {
    // result === 15
});

If pass boolean true as first argument, then return sum of entire matrix.

jStat([[1,2],[3,4]]).sum( true ) === 10

And the two can be combined.

jStat[[1,2],[3,4]]).sum(true,function( result ) {
    // result === 10
});

sumsqrd()

sumsqrd( array )

Return the sum squared of a vector.

jStat.sumsqrd([1,2,3]) === 14

fn.sumsqrd( [bool][,callback] )

Return the sum squared of a vector or matrix columns.

jStat( 1, 5, 5 ).sumsqrd() === 55
jStat([[1,2],[3,4]]).sumsqrd() === [ 10, 20 ]

If callback is passed then will pass result as first argument.

jStat( 1, 5, 5 ).sumsqrd(function( result ) {
    // result === 55
});

If pass boolean true as first argument, then return sum squared of entire matrix.

jStat([[1,2],[3,4]]).sumsqrd( true ) === 650

And the two can be combined.

jStat[[1,2],[3,4]]).sumsqrd(true,function( result ) {
    // result === 650
});

sumsqerr()

sumsqerr( array )

Return the sum of squared errors of prediction of a vector.

jStat.sumsqerr([1,2,3]) === 2

fn.sumsqerr( [bool][,callback] )

Return the sum of squared errors of prediction of a vector or matrix columns.

jStat( 1, 5, 5 ).sumsqerr() === 10
jStat([[1,2],[3,4]]).sumsqerr() === [ 2, 2 ]

If callback is passed then will pass result as first argument.

jStat( 1, 5, 5 ).sumsqerr(function( result ) {
    // result === 55
});

If pass boolean true as first argument, then return sum of squared errors of entire matrix.

jStat([[1,2],[3,4]]).sumsqerr( true ) === 0

And the two can be combined.

jStat[[1,2],[3,4]]).sumsqerr(true,function( result ) {
    // result === 0
});

product()

product( array )

Return the product of a vector.

jStat.product([1,2,3]) === 6

fn.product( [bool][,callback] )

Return the product of a vector or matrix columns.

jStat( 1, 5, 5 ).product() === 120
jStat([[1,2],[3,4]]).product() === [ 3, 8 ]

If callback is passed then will pass result as first argument.

jStat( 1, 5, 5 ).product(function( result ) {
    // result === 120
});

If pass boolean true as first argument, then return sumsqerr of entire matrix.

jStat([[1,2],[3,4]]).product( true ) === 24

And the two can be combined.

jStat[[1,2],[3,4]]).product(true,function( result ) {
    // result === 24
});

min()

min( array )

Return the minimum value of a vector.

jStat.min([1,2,3]) === 1

fn.min( [bool][,callback] )

Return the minimum value of a vector or matrix columns.

jStat( 1, 5, 5 ).min() === 1
jStat([[1,2],[3,4]]).min() === [ 1, 2 ]

If callback is passed then will pass result as first argument.

jStat( 1, 5, 5 ).min(function( result ) {
    // result === 1
});

If pass boolean true as first argument, then return minimum of entire matrix.

jStat([[1,2],[3,4]]).min( true ) === 1

And the two can be combined.

jStat[[1,2],[3,4]]).min(true,function( result ) {
    // result === 1
});

max()

max( array )

Return the maximum value of a vector.

jStat.max([1,2,3]) === 3

fn.max( [bool][,callback] )

Return the maximum value of a vector or matrix columns.

jStat( 1, 5, 5 ).max() === 5
jStat([[1,2],[3,4]]).max() === [ 3, 4 ]

If callback is passed then will pass result as first argument.

jStat( 1, 5, 5 ).max(function( result ) {
    // result === 5
});

If pass boolean true as first argument, then return maximum of entire matrix.

jStat([[1,2],[3,4]]).max( true ) === 4

And the two can be combined.

jStat[[1,2],[3,4]]).max(true,function( result ) {
    // result === 4
});

mean()

mean( array )

Return the mean of a vector.

jStat.mean([1,2,3]) === 2

fn.max( [bool,][callback] )

Return the mean of a vector or matrix columns.

jStat( 1, 5, 5 ).mean() === 3
jStat([[1,2],[3,4]]).mean() === [ 2, 3 ]

If callback is passed then will pass result as first argument.

jStat( 1, 5, 5 ).mean(function( result ) {
    // result === 3
});

If pass boolean true as first argument, then return mean of entire matrix.

jStat([[1,2],[3,4]]).mean( true ) === 2.5

And the two can be combined.

jStat[[1,2],[3,4]]).mean(true,function( result ) {
    // result === 2.5
});

meansqerr()

meansqerr( array )

Return the mean squared error of a vector.

jStat.meansqerr([1,2,3]) === 0.66666...

fn.meansqerr( [bool][,callback] )

Return the mean squared error of a vector or matrix columns.

jStat( 1, 5, 5 ).meansqerr() === 2
jStat([[1,2],[3,4]]).meansqerr() === [ 1, 1 ]

If callback is passed then will pass result as first argument.

jStat( 1, 5, 5 ).meansqerr(function( result ) {
    // result === 2
});

If pass boolean true as first argument, then return mean squared error of entire matrix.

jStat([[1,2],[3,4]]).meansqerr( true ) === 0

And the two can be combined.

jStat[[1,2],[3,4]]).meansqerr(true,function( result ) {
    // result === 0
});

geomean()

geomean( array )

Return the geometric mean of a vector.

jStat.geomean([4,1,1/32]) === 0.5

fn.geomean( [bool][,callback] )

Return the geometric mean of a vector or matrix columns.

jStat([4,1,1\32]).geomean() === 0.5
jStat([[1,2],[3,4]]).geomean() === [ 1.732..., 2.828... ]

If callback is passed then will pass result as first argument.

jStat([4,1,1\32]).geomean(function( result ) {
    // result === 0.5
});

If pass boolean true as first argument, then return geometric mean of entire matrix.

jStat([[1,2],[3,4]]).geomean( true ) === 2.213...

And the two can be combined.

jStat[[1,2],[3,4]]).geomean(true,function( result ) {
    // result === 2.213...
});

median()

median( array )

Return the median of a vector.

jStat.median([1,2,3]) === 2

fn.median( [bool][,callback] )

Return the median of a vector or matrix columns.

jStat( 1, 5, 5 ).median() === 3
jStat([[1,2],[3,4]]).median() === [ 2, 3 ]

If callback is passed then will pass result as first argument.

jStat( 1, 5, 5 ).median(function( result ) {
    // result === 3
});

If pass boolean true as first argument, then return median of entire matrix.

jStat([[1,2],[3,4]]).median( true ) === 2.5

And the two can be combined.

jStat[[1,2],[3,4]]).median(true,function( result ) {
    // result === 2.5
});

cumsum()

cumsum( array )

Return an array of partial sums in the sequence.

jStat.cumsum([1,2,3]) === [1,3,6]

fn.cumsum( [bool][,callback] )

Return an array of partial sums for a vector or matrix columns.

jStat( 1, 5, 5 ).cumsum() === [1,3,6,10,15]
jStat([[1,2],[3,4]]).cumsum() === [[1,4],[2,6]]

If callback is passed then will pass result as first argument.

jStat( 1, 5, 5 ).cumsum(function( result ) {
    // result === [1,3,6,10,15]
});

If pass boolean true as first argument, then return cumulative sums of the matrix.

jStat([[1,2],[3,4]]).cumsum( true ) === [[1,3],[3,7]]

And the two can be combined.

jStat([[1,2],[3,4]]).cumsum(true,function( result ) {
    // result === ...
});

diff()

diff( array )

Return an array of the successive differences of the array.

jStat.diff([1,2,2,3]) === [1,0,1]

fn.diff( [bool][,callback] )

Return an array of successive differences for a vector or matrix columns.

jStat([1,2,2,3]).diff() === [1,0,1]
jStat([[1,2],[3,4],[1,4]]).diff() === [[2,-2],[2,0]]

If callback is passed then will pass result as first argument.

jStat([[1,2],[3,4],[1,4]]).diff(function( result ) {
    // result === [[2,-2],[2,0]]
});

If pass boolean true as first argument, then return successive difference for the whole matrix.

jStat([[1,2],[3,4],[1,4]]).diff(true) === [0,2]

And the two can be combined.

jStat([[1,2],[3,4],[1,4]]).diff(true,function( result ) {
    // result === [0,2]
});

mode()

mode( array )

Return the mode of a vector. If there are multiple modes then mode() will return all of them.

jStat.mode([1,2,2,3]) === 2
jStat.mode([1,2,3]) === [1,2,3]

fn.mode( [bool][,callback] )

Return the mode for a vector or matrix columns.

jStat([1,2,2,3]).mode() === 2
jStat([[1,2],[3,4],[1,4]]).mode() === [1,4]

If callback is passed then will pass result as first argument.

jStat( 1, 5, 5 ).mode(function( result ) {
    // result === false
});

If pass boolean true as first argument, then return mode of the matrix.

jStat([[1,2],[1,2]]).mode( true ) === [[1,2],[1,2]]

And the two can be combined.

jStat[[1,2],[1,2]]).mode(true,function( result ) {
    // result === false
});

range()

range( array )

Return the range of a vector

jStat.range([1,2,3]) === 2

fn.range( [bool][,callback] )

Return the range for a vector or matrix columns.

jStat([1,2,3]).range() === 2
jStat([[1,2],[3,4]]).range() === [2,2]

If callback is passed then will pass result as first argument.

jStat( 1, 5, 5 ).range(function( result ) {
    // result === 4
});

If pass boolean true as first argument, then return range of the matrix.

jStat([[1,2],[3,5]]).range( true ) === true

And the two can be combined.

jStat[[1,2],[3,5]]).range(true,function( result ) {
    // result === 1
});

variance()

variance( array[,flag])

Return the variance of a vector. Flag indicates whether to compute population or sample.

jStat.variance([1,2,3,4]) === 1.25
jStat.variance([1,2,3,4],true) === 1.66666...

fn.variance( [bool][,callback] )

Return the variance for a vector or matrix columns.

Note: Cannot pass flag to indicate between population or sample for matrices. There is a feature request for this on Issue #51.

jStat([1,2,3,4]).variance() === 1.25
jStat([[1,2],[3,4]]).variance() === [1,1]

If callback is passed then will pass result as first argument.

jStat( 1, 5, 5 ).variance(function( result ) {
    // result === 2
});

If pass boolean true as first argument, then return variance of the matrix.

jStat([[1,2],[3,5]]).variance( true ) === 0.140625

And the two can be combined.

jStat[[1,2],[3,5]]).variance(true,function( result ) {
    // result === 0.140625
});

stdev()

stdev( array[,flag])

Return the standard deviation of a vector. Flag indicates whether to compute population or sample.

jStat.stdev([1,2,3,4]) === 1.118...
jStat.stdev([1,2,3,4],true) === 1.290...

fn.stdev( [bool][,callback] )

Return the standard deviation for a vector or matrix columns.

Note: Cannot pass flag to indicate between population or sample for matrices. There is a feature request for this on Issue #51.

jStat([1,2,3,4]).stdev() === 1.118...
jStat([1,2,3,4]).stdev(true) === 1.290...
jStat([[1,2],[3,4]]).stdev() === [1,1]

If callback is passed then will pass result as first argument.

jStat( 1, 4, 4 ).stdev(function( result ) {
    // result === 1.118...
});
jStat( 1, 4, 4 ).stdev(true,function( result ) {
    // result === 1.290...
});

If pass boolean true as first argument, then return variance of the matrix.

jStat([[1,2],[3,5]]).stdev( true ) === 0.25

And the two can be combined.

jStat[[1,2],[3,5]]).stdev(true,function( result ) {
    // result === 0.25
});

meandev()

meandev( array )

Return the mean absolute deviation of a vector.

jStat.meandev([1,2,3,4]) === 1

fn.meandev( [bool][,callback] )

Return the mean absolute deviation for a vector or matrix columns.

jStat([1,2,3,4]).meandev() === 1
jStat([[1,2],[3,4]]).meandev() === [1,1]

If callback is passed then will pass result as first argument.

jStat( 1, 4, 4 ).meandev(function( result ) {
    // result === 1
});

If pass boolean true as first argument, then return mean absolute deviation of the matrix.

jStat([[1,2],[3,5]]).meandev( true ) === 0.25

And the two can be combined.

jStat[[1,2],[3,5]]).meandev(true,function( result ) {
    // result === 0.25
});

meddev()

meddev( array )

Return the median absolute deviation of a vector.

jStat.meddev([1,2,3,4]) === 1

fn.meddev( [bool][,callback] )

Return the median absolute deviation for a vector or matrix columns.

jStat([1,2,3,4]).meddev() === 1
jStat([[1,2],[3,4]]).meddev() === [1,1]

If callback is passed then will pass result as first argument.

jStat( 1, 4, 4 ).meddev(function( result ) {
    // result === 1
});

If pass boolean true as first argument, then return median absolute deviation of the matrix.

jStat([[1,2],[3,5]]).meddev( true ) === 0.25

And the two can be combined.

jStat[[1,2],[3,5]]).meddev(true,function( result ) {
    // result === 0.25
});

coeffvar()

coeffvar( array )

Return the coefficient of variation of a vector.

jStat.coeffvar([1,2,3,4]) === 0.447...

fn.coeffvar( [bool][,callback] )

Return the coefficient of variation for a vector or matrix columns.

jStat([1,2,3,4]).coeffvar() === 0.447...
jStat([[1,2],[3,4]]).coeffvar() === [0.5,0.333...]

If callback is passed then will pass result as first argument.

jStat( 1, 4, 4 ).coeffvar(function( result ) {
    // result === 0.447...
});

If pass boolean true as first argument, then return coefficient of variation of the matrix.

jStat([[1,2],[3,5]]).coeffvar( true ) === 0.142...

And the two can be combined.

jStat[[1,2],[3,5]]).coeffvar(true,function( result ) {
    // result === 0.142...
});

quartiles()

quartiles( array )

Return the quartiles of a vector.

jStat.quartiles( jStat.seq(1,100,100)) === [25,50,75]

fn.quartiles( [callback] )

Return the quartiles for a vector or matrix columns.

jStat(1,100,100).quartiles() === [25,50,75]
jStat(1,100,100,function( x ) {
    return [x,x];
}).quartiles() === [[25,50,75],[25,50,75]]

If callback is passed then will pass result as first argument.

jStat(1,100,100).quartiles(function( result ) {
    // result === [25,50,75]
});

covariance()

covariance( array, array )

Return the covariance of two vectors.

var seq = jStat.seq( 0, 10, 11 );
jStat.covariance( seq, seq ) === 11;

corrcoeff()

corrcoeff( array, array )

Return the correlation coefficient of two vectors.

var seq = jStat.seq( 0, 10, 11 );
jStat.corrcoeff( seq, seq ) === 1;

Distributions

jStat.beta( alpha, beta )

jStat.beta.pdf( x, alpha, beta )

Returns the value of x in the Beta distribution with parameters alpha and beta.

jStat.beta.cdf( x, alpha, beta )

Returns the value of x in the cdf for the Beta distribution with parameters alpha and beta.

jStat.beta.inv( p, alpha, beta )

Returns the value of p in the inverse of the cdf for the Beta distribution with parameters alpha and beta.

jStat.beta.mean( alpha, beta )

Returns the mean of the Beta distribution with parameters alpha and beta.

jStat.beta.median( alpha, beta )

Returns the median of the Beta distribution with parameters alpha and beta.

jStat.beta.mode( alpha, beta )

Returns the mode of the Beta distribution with parameters alpha and beta.

jStat.beta.sample( alpha, beta )

Returns a random number whose distribution is the Beta distribution with parameters alpha and beta.

jStat.beta.variance( alpha, beta )

Returns the variance of the Beta distribution with parameters alpha and beta.

jStat.centralF( df1, df2 )

jStat.centralF.pdf( x, df1, df2 )

Returns the value of x in the pdf of the (Central) F distribution with numerator degrees of freedom df1 and denominator degrees of freedom df2.

jStat.centralF.cdf( x, df1, df2 )

Returns the value of x in the cdf of the (Central) F distribution with numerator degrees of freedom df1 and denominator degrees of freedom df2.

jStat.centralF.inv( x, df1, df2 )

Returns the value of x in the inverse of the cdf for the (Central) F distribution with numerator degrees of freedom df1 and denominator degrees of freedom df2.

jStat.centralF.mean( df1, df2 )

Returns the mean of the (Central) F distribution with numerator degrees of freedom df1 and denominator degrees of freedom df2.

jStat.centralF.mode( df1, df2 )

Returns the mode of the (Central) F distribution with numerator degrees of freedom df1 and denominator degrees of freedom df2.

jStat.centralF.sample( df1, df2 )

Returns a random number whose distribution is the (Central) F distribution with numerator degrees of freedom df1 and denominator degrees of freedom df2.

jStat.centralF.variance( df1, df2 )

Returns the variance of the (Central) F distribution with numerator degrees of freedom df1 and denominator degrees of freedom df2.

jStat.cauchy( local, scale )

jStat.cauchy.pdf( x, local, scale )

Returns the value of x in the pdf of the Cauchy distribution with a location (median) of local and scale factor of scale.

jStat.cauchy.cdf( x, local, scale )

Returns the value of x in the cdf of the Cauchy distribution with a location (median) of local and scale factor of scale.

jStat.cauchy.inv( p, local, scale )

Returns the value of p in the inverse of the cdf for the Cauchy distribution with a location (median) of local and scale factor of scale.

jStat.cauchy.median( local, scale )

Returns the value of the median for the Cauchy distribution with a location (median) of local and scale factor of scale.

jStat.cauchy.mode( local, scale )

Returns the value of the mode for the Cauchy distribution with a location (median) of local and scale factor of scale.

jStat.cauchy.sample( local, scale )

Returns a random number whose distribution is the Cauchy distribution with a location (median) of local and scale factor of scale.

jStat.cauchy.variance( local, scale )

Returns the value of the variance for the Cauchy distribution with a location (median) of local and scale factor of scale.

jStat.chisquare( dof )

jStat.chisquare.pdf( x, dof )

Returns the value of x in the pdf of the Chi Square distribution with degrees of freedom dof.

jStat.chisquare.cdf( x, dof )

Returns the value of x in the cdf of the Chi Square distribution with degrees of freedom dof.

jStat.chisquare.inv( p, dof )

Returns the value of x in the inverse of the cdf for the Chi Square distribution with degrees of freedom dof.

jStat.chisquare.mean( dof )

Returns the value of the mean for the Chi Square distribution with degrees of freedom dof.

jStat.chisquare.median( dof )

Returns the value of the median for the Chi Square distribution with degrees of freedom dof.

jStat.chisquare.mode( dof )

Returns the value of the mode for the Chi Square distribution with degrees of freedom dof.

jStat.chisquare.sample( dof )

Returns a random number whose distribution is the Chi Square distribution with degrees of freedom dof.

jStat.chisquare.variance( dof )

Returns the value of the variance for the Chi Square distribution with degrees of freedom dof.

jStat.exponential( rate )

jStat.exponential.pdf( x, rate )

Returns the value of x in the pdf of the Exponential distribution with the parameter rate (lambda).

jStat.exponential.cdf( x, rate )

Returns the value of x in the cdf of the Exponential distribution with the parameter rate (lambda).

jStat.exponential.inv( rate )

Returns the value of x in the inverse of the cdf for the Exponential distribution with the parameter rate (lambda).

jStat.exponential.mean( rate )

Returns the value of the mean for the Exponential distribution with the parameter rate (lambda).

jStat.exponential.median( rate )

Returns the value of the median for the Exponential distribution with the parameter rate (lambda)

jStat.exponential.mode( rate )

Returns the value of the mode for the Exponential distribution with the parameter rate (lambda).

jStat.exponential.sample( rate )

Returns a random number whose distribution is the Exponential distribution with the parameter rate (lambda).

jStat.exponential.variance( rate )

Returns the value of the variance for the Exponential distribution with the parameter rate (lambda).

jStat.gamma( shape, scale )

jStat.gamma.pdf( x, shape, scale )

Returns the value of x in the pdf of the Gamma distribution with the parameters shape (k) and scale (theta). Notice that if using the alpha beta convention, scale = 1/beta.

jStat.gamma.cdf( x, shape, scale )

Returns the value of x in the cdf of the Gamma distribution with the parameters shape (k) and scale (theta). Notice that if using the alpha beta convention, scale = 1/beta.

jStat.gamma.inv( p, shape, scale )

Returns the value of p in the inverse of the cdf for the Gamma distribution with the parameters shape (k) and scale (theta). Notice that if using the alpha beta convention, scale = 1/beta.

jStat.gamma.mean( shape, scale )

Returns the value of the mean for the Gamma distribution with the parameters shape (k) and scale (theta). Notice that if using the alpha beta convention, scale = 1/beta.

jStat.gamma.mode( shape, scale )

Returns the value of the mode for the Gamma distribution with the parameters shape (k) and scale (theta). Notice that if using the alpha beta convention, scale = 1/beta.

jStat.gamma.sample( shape, scale )

Returns a random number whose distribution is the Gamma distribution with the parameters shape (k) and scale (theta). Notice that if using the alpha beta convention, scale = 1/beta.

jStat.gamma.variance( shape, scale )

Returns the value of the variance for the Gamma distribution with the parameters shape (k) and scale (theta). Notice that if using the alpha beta convention, scale = 1/beta.

jStat.invgamma( shape, scale )

jStat.invgamma.pdf( x, shape, scale )

Returns the value of x in the pdf of the Inverse-Gamma distribution with parametres shape (alpha) and scale (beta).

jStat.invgamma.cdf( x, shape, scale )

Returns the value of x in the cdf of the Inverse-Gamma distribution with parametres shape (alpha) and scale (beta).

jStat.invgamma.inv( p, shape, scale )

Returns the value of p in the inverse of the cdf for the Inverse-Gamma distribution with parametres shape (alpha) and scale (beta).

jStat.invgamma.mean( shape, scale )

Returns the value of the mean for the Inverse-Gamma distribution with parametres shape (alpha) and scale (beta).

jStat.invgamma.mode( shape, scale )

Returns the value of the mode for the Inverse-Gamma distribution with parametres shape (alpha) and scale (beta).

jStat.invgamma.sample( shape, scale )

Returns a random number whose distribution is the Inverse-Gamma distribution with parametres shape (alpha) and scale (beta).

jStat.invgamma.variance( shape, scale )

Returns the value of the variance for the Inverse-Gamma distribution with parametres shape (alpha) and scale (beta).

jStat.kumaraswamy( alpha, beta )

jStat.kumaraswamy.pdf( x, a, b )

Returns the value of x in the pdf of the Kumaraswamy distribution with parameters a and b.

jStat.kumaraswamy.cdf( x, alpha, beta )

Returns the value of x in the cdf of the Kumaraswamy distribution with parameters a and b.

jStat.kumaraswamy.mean( alpha, beta )

Returns the value of the mean of the Kumaraswamy distribution with parameters a and b.

jStat.kumaraswamy.median( alpha, beta )

Returns the value of the median of the Kumaraswamy distribution with parameters a and b.

jStat.kumaraswamy.mode( alpha, beta )

Returns the value of the mode of the Kumaraswamy distribution with parameters a and b.

jStat.kumaraswamy.variance( alpha, beta )

Returns the value of the variance of the Kumaraswamy distribution with parameters a and b.

jStat.lognormal( mu, sigma )

jStat.lognormal.pdf( x, mu, sigma )

Returns the value of x in the pdf of the Log-normal distribution with paramters mu (mean) and sigma (standard deviation).

jStat.lognormal.cdf( x, mu, sigma )

Returns the value of x in the cdf of the Log-normal distribution with paramters mu (mean) and sigma (standard deviation).

jStat.lognormal.inv( p, mu, sigma )

Returns the value of x in the inverse of the cdf for the Log-normal distribution with paramters mu (mean of the Normal distribution) and sigma (standard deviation of the Normal distribution).

jStat.lognormal.mean( mu, sigma )

Returns the value of the mean for the Log-normal distribution with paramters mu (mean of the Normal distribution) and sigma (standard deviation of the Normal distribution).

jStat.lognormal.median( mu, sigma )

Returns the value of the median for the Log-normal distribution with paramters mu (mean of the Normal distribution) and sigma (standard deviation of the Normal distribution).

jStat.lognormal.mode( mu, sigma )

Returns the value of the mode for the Log-normal distribution with paramters mu (mean of the Normal distribution) and sigma (standard deviation of the Normal distribution).

jStat.lognormal.sample( mu, sigma )

Returns a random number whose distribution is the Log-normal distribution with paramters mu (mean of the Normal distribution) and sigma (standard deviation of the Normal distribution).

jStat.lognormal.variance( mu, sigma )

Returns the value of the variance for the Log-normal distribution with paramters mu (mean of the Normal distribution) and sigma (standard deviation of the Normal distribution).

jStat.normal( mean, std )

jStat.normal.pdf( x, mean, std )

Returns the value of x in the pdf of the Normal distribution with parameters mean and std (standard deviation).

jStat.normal.cdf( x, mean, std )

Returns the value of x in the cdf of the Normal distribution with parameters mean and std (standard deviation).

jStat.normal.inv( p, mean, std )

Returns the value of p in the inverse cdf for the Normal distribution with parameters mean and std (standard deviation).

jStat.normal.mean( mean, std )

Returns the value of the mean for the Normal distribution with parameters mean and std (standard deviation).

jStat.normal.median( mean, std )

Returns the value of the median for the Normal distribution with parameters mean and std (standard deviation).

jStat.normal.mode( mean, std )

Returns the value of the mode for the Normal distribution with parameters mean and std (standard deviation).

jStat.normal.sample( mean, std )

Returns a random number whose distribution is the Normal distribution with parameters mean and std (standard deviation).

jStat.normal.variance( mean, std )

Returns the value of the variance for the Normal distribution with parameters mean and std (standard deviation).

jStat.pareto( scale, shape )

jStat.pareto.pdf( x, scale, shape )

Returns the value of x in the pdf of the Pareto distribution with parameters scale (x_m) and shape (alpha).

jStat.pareto.cdf( x, scale, shape )

Returns the value of x in the cdf of the Pareto distribution with parameters scale (x_m) and shape (alpha).

jStat.pareto.mean( scale, shape )

Returns the value of the mean of the Pareto distribution with parameters scale (x_m) and shape (alpha).

jStat.pareto.median( scale, shape )

Returns the value of the median of the Pareto distribution with parameters scale (x_m) and shape (alpha).

jStat.pareto.mode( scale, shape )

Returns the value of the mode of the Pareto distribution with parameters scale (x_m) and shape (alpha).

jStat.pareto.variance( scale, shape )

Returns the value of the variance of the Pareto distribution with parameters scale (x_m) and shape (alpha).

jStat.studentt( dof )

jStat.studentt.pdf( x, dof )

Returns the value of x in the pdf of the Student's T distribution with degrees of freedom dof.

jStat.studentt.cdf( x, dof )

Returns the value of x in the cdf of the Student's T distribution with degrees of freedom dof.

jStat.studentt.inv( p, dof )

Returns the value of p in the inverse of the cdf for the Student's T distribution with degrees of freedom dof.

jStat.studentt.mean( dof )

Returns the value of the mean of the Student's T distribution with degrees of freedom dof.

jStat.studentt.median( dof )

Returns the value of the median of the Student's T distribution with degrees of freedom dof.

jStat.studentt.mode( dof )

Returns the value of the mode of the Student's T distribution with degrees of freedom dof.

jStat.studentt.sample( dof )

Returns a random number whose distribution is the Student's T distribution with degrees of freedom dof.

jStat.studentt.variance( dof )

Returns the value of the variance for the Student's T distribution with degrees of freedom dof.

jStat.weibull( scale, shape )

jStat.weibull.pdf( x, scale, shape )

Returns the value x in the pdf for the Weibull distribution with parameters scale (lambda) and shape (k).

jStat.weibull.cdf( x, scale, shape )

Returns the value x in the cdf for the Weibull distribution with parameters scale (lambda) and shape (k).

jStat.weibull.inv( p, scale, shape )

Returns the value of x in the inverse of the cdf for the Weibull distribution with parameters scale (lambda) and shape (k).

jStat.weibull.mean( scale, shape )

Returns the value of the mean of the Weibull distribution with parameters scale (lambda) and shape (k).

jStat.weibull.median( scale, shape )

Returns the value of the median of the Weibull distribution with parameters scale (lambda) and shape (k).

jStat.weibull.mode( scale, shape )

Returns the mode of the Weibull distribution with parameters scale (lambda) and shape (k).

jStat.weibull.sample( scale, shape )

Returns a random number whose distribution is the Weibull distribution with parameters scale (lambda) and shape (k).

jStat.weibull.variance( scale, shape )

Returns the variance of the Weibull distribution with parameters scale (lambda) and shape (k).

jStat.uniform( a, b )

jStat.uniform.pdf( x, a, b )

Returns the value of x in the pdf of the Uniform distribution from a to b.

jStat.uniform.cdf( x, a, b )

Returns the value of x in the cdf of the Uniform distribution from a to b.

jStat.uniform.mean( a, b )

Returns the value of the mean of the Uniform distribution from a to b.

jStat.uniform.median( a, b )

Returns the value of the median of the Uniform distribution from a to b.

jStat.uniform.mode( a, b )

Returns the value of the mode of the Uniform distribution from a to b.

jStat.uniform.sample( a, b )

Returns a random number whose distribution is the Uniform distribution from a to b.

jStat.uniform.variance( a, b )

Returns the variance of the Uniform distribution from a to b.

jStat.binomial

jStat.binomial.pdf( k, n, p )

Returns the value of k in the pdf of the Binomial distribution with parameters n and p.

jStat.binomial.cdf( k, n, p )

Returns the value of k in the cdf of the Binomial distribution with parameters n and p.

jStat.negbin

jStat.negbin.pdf( k, r, p )

Returns the value of k in the pdf of the Negative Binomial distribution with parameters n and p.

jStat.negbin.cdf( x, r, p )

Returns the value of x in the cdf of the Negative Binomial distribution with parameters n and p.

jStat.hypgeom

jStat.hypgeom.pdf( k, N, m, n )

Returns the value of k in the pdf of the Hypergeometric distribution with parameters N (the population size), m (the success rate), and n (the number of draws). #### jStat.hypgeom.cdf( x, N, m, n )

Returns the value of k in the pdf of the Hypergeometric distribution with parameters N (the population size), m (the success rate), and n (the number of draws).

jStat.poisson

jStat.poisson.pdf( k, l )

Returns the value of k in the pdf of the Poisson distribution with parameter l (lambda).

jStat.poisson.cdf( x, l )

Returns the value of x in the cdf of the Poisson distribution with parameter l (lambda).

jStat.triangular

jStat.triangular.pdf( x, a, b, c )

Returns the value of x in the pdf of the Triangular distribution with the parameters a, b, and c.

jStat.triangular.cdf( x, a, b, c )

Returns the value of x in the cdf of the Triangular distribution with the parameters a, b, and c.

jStat.triangular.mean( a, b, c )

Returns the value of the mean of the Triangular distribution with the parameters a, b, and c.

jStat.triangular.median( a, b, c )

Returns the value of the median of the Triangular distribution with the parameters a, b, and c.

jStat.triangular.mode( a, b, c )

Returns the value of the mode of the Triangular distribution with the parameters a, b, and c.

jStat.triangular.variance( a, b, c )

Returns the value of the variance of the Triangular distribution with the parameters a, b, and c.

Special Functions

betafn( x, y )

Evaluates the Beta function at (x,y).

betaln( x, y )

Evaluates the log Beta function at (x,y).

betacf( x, a, b )

Returns the continued fraction for the incomplete Beta function with parameters a and b modified by Lentz's method evaluated at x.

ibetainv( p, a, b)

Returns the inverse of the incomplete Beta function evaluated at (p,a,b).

ibeta( x, a, b)

Returns teh incomplete Beta function evaluated at (x,a,b).

gammaln( x )

Returns the Log-Gamma function evaluated at x.

gammafn( x )

Returns the Gamma function evaluated at x.

gammap( a, x )

Returns the Lower Incomplete Gamma function evaluated at (a,x).

factorialln( n )

Returns the natural log factorial of n.

factorial( n )

Returns the factorial of n.

combination( n, m )

Returns the number of combinations of n, m.

permutation( n, m )

Returns the number of permutations of n, m.

gammapinv( p, a )

Returns the inverse of the incomplete Gamma function evaluated at (p,a).

erf( x )

Returns the error function evaluated at x.

erfc( x )

Returns the complementary error function evaluated at x.

erfcinv( p )

Returns the inverse of the complementary error function evaluated at p.

randn( n, m )

Returns a normal deviate (mean 0 and standard deviation 1).

randg( shape, n, m )

Returns a Gamma deviate by the method of Marsaglia and Tsang.

Linear Algebra

Instance Functionality

add( arg )

Add value to all entries.

jStat([[1,2,3]]).add( 2 ) === [[3,4,5]];

subtract( arg )

Subtract all entries by value.

jStat([[4,5,6]]).subtract( 2 ) === [[2,3,4]];

divide( arg )

Divide all entries by value.

jStat([[2,4,6]]).divide( 2 ) === [[1,2,3]];

multiply( arg )

Multiply all entries by value.

jStat([[1,2,3]]).multiply( 2 ) === [[2,4,6]];

dot( arg )

Take dot product.

pow( arg )

Raise all entries by value.

jStat([[1,2,3]]).pow( 2 ) === [[1,4,9]];

abs()

Return the absolute values of all entries.

jStat([[1,-2,-3]]).abs() === [[1,2,3]];

norm()

Compulte the norm of a vector.

angle( arg )

Compute the angle between two vectors.

Static Functionality

add( arr, arg )

Add arg to all entries of the array

subtract( arr, arg )

Subtract all entries of the array by arg

divide( arr, arg )

Divide all entries of the array by arg.

multiply( arr, arg )

Multiply all entries of the array by arg.

dot( arr1, arr2 )

Take dot product of array 1 and array 2.

pow( arr, arg )

Raise all entries of the array to the power of arg

abs(arr)

Return the absolute values of all entries in the array

norm(arr)

Compulte the norm of a vector.

angle( arr1, arr2 )

Compute the angle between two vectors.

aug(A,B)

Augments matrix A by matrix B

det(A)

Calculates the determinant of matrix A.

inv(A)

Returns the inverse of the matrix A.

gauss_elimination(A,B)

Performs Gaussian Elimination on matrix A augmented by matrix B.

gauss_jordan(A,B)

Performs Gauss-Jordan Elimination on matrix A augmented by matrix B.

lu(A,B)

Performs the LU-Decomposition on matrix A.

cholesky(A)

Performs the Cholesky decomposition on matrix A.

gauss_jacobi(A,b,x,r)

Solves the linear system Ax = b using the Gauss-Jacobi method with an initial guess of r.

gauss_seidel(A,b,x,r)

Solves the linear system Ax = b using the Gauss-Seidel method with an initial guess of r.

SOR(A,b,x,r,w)

Solves the linear system Ax = b using the sucessive over-relaxation method with an initial guess of r and parameter w (omega).

householder(A)

Performs the householder transformation on the matrix A.

QR()

jacobi()

rungekutta()

romberg()

richardson()

simpson()

hermite()

lagrange()

cubic_spline()

gauss_quadrature()

PCA()

Statistical Tests

The test module includes methods that enact popular statistical tests. The tests that are implemented are Z tests, T tests, and F tests. Also included are methods for developing confidence intervals. Currently regression is not included but it should be included soon (once matrix inversion is fixed).

Statistics Instance Functionality

zscore( value[, flag])

Returns the z-score of the value taking the jStat object as the observed values. Flag==true denotes use of sample standard deviation.

ztest( value, sides[, flag])

Returns the p-value of the value taking the jStat object as the observed values. Sides is an integer value 1 or 2 denoting a 1 or 2 sided z-test. The test defaults to a 2 sided z-test if sides is not specified.Flag==true denotes use of sample standard devaition.

tscore( value)

Returns the t-score of the value taking the jStat object as the observed values.

ttest( value, sides)

Returns the p-value of the value taking the jStat object as the observed values. Sides is an integer value 1 or 2 denoting a 1 or 2 sided t-test. The test defaults to a 2 sided t-test if sides is not specified.

anovafscore()

Returns the f-score of the ANOVA test on the arrays of the jStat object.

anovaftest()

Returns the p-value of an ANOVA test on the arrays of the jStat object.

Static Methods

Z Statistics

jStat.zscore( value, mean, sd)

Returns the z-score of value given the mean and the standard deviation of the test.

jStat.zscore( value, array[, flag])

Returns the z-score of value given the data from array. Flag==true denotes use of the sample standard deviation.

jStat.ztest( value, mean, sd, sides)

Returns the p-value of a the z-test of value given the mean and standard deviation of the test. Sides is an integer value 1 or 2 denoting a one or two sided z-test. If sides is not specified the test defaults to a two sided z-test.

jStat.ztest( zscore, sides)

Returns the p-value of the z-score. Sides is an integer value 1 or 2 denoting a one or two sided z-test. If sides is not specified the test defaults to a two sided z-test

jStat.ztest( value, array, sides[, flag])

Returns the p-value of value given the data from the array. Sides is an integer value 1 or 2 denoting a one or two sided z-test. If sides is not specified the test defaults to a two sided z-test. flag==true denotes the use of the sample standard deviation.

T Statistics

jStat.tscore( value, mean, sd, n)

Returns the t-score of the value given the mean, standard deviation, and the sample size n.

jStat.tscore( value, array)

Returns the t-score of value given the data from the array.

jStat.ttest( value, mean, sd, n, sides)

Returns the p-value of value given the mean, standard deviation, and the sample size n. Sides is an integer value 1 or 2 denoting a one or two sided t-test. If sides is not specified the test defaults to a two sided t-test.

jStat.ttest( tscore, n, sides)

Returns the p-value of the t-score given the sample size n. Sides is an integer value 1 or 2 denoting a one or two sided t-test. If sides is not specified the test defaults to a two sided t-test.

jStat.ttest( value, array, sides)

Returns the p-value of the value given the data in the array. Sides is an integer value 1 or 2 denoting a one or two sided t-test. If sides is not specified the test defaults to a two sided t-test.

F Statistics

jStat.anovafscore( array1, array2, ..., arrayn)

Returns the f-score of an ANOVA on the arrays.

jStat.anovafscore( [array1,array2, ...,arrayn])

Returns the f-score of an ANOVA on the arrays.

jStat.anovaftest( array1, array2, ...., arrayn)

Returns the p-value of the f-statistic from the ANOVA test on the arrays.

jStat.ftest( fscore, df1, df2)

Returns the p-value for the fscore with a numerator degress of freedom df1 and the denominator degrees of freedom df2

Confidence Intervals

jStat.normalci( value, alpha, sd, n)

Returns a 1-alpha confidence interval for the value given a normal distribution with a standard deviation sd and a sample size n

jStat.normalci( value, alpha, array)

Returns a 1-alpha confidence interval for the value given a normal distribution in the data from the array.

jStat.tci( value, alpha, sd, n)

Returns a 1-alpha confidence interval for the value given the standard deviation and the sample size n.

jStat.tci( value, alpha, array)

Returns a 1-alpha confidence interval for the value given the data from the array.