streaming

streaming

Source:

Streaming

Methods

(static) covariance() → {Stream}

Source:

Covariance — cov is a higher order function that returns a Stream

The result() returns an object containing sample covariance cov, along with meanX, meanY and size of data i.e. number of x & y pairs. It also contains population covariance covp.

Example
var covariance = cov();
covariance.compute( 10, 80 );
covariance.compute( 15, 75 );
covariance.compute( 16, 65 );
covariance.compute( 18, 50 );
covariance.compute( 21, 45 );
covariance.compute( 30, 30 );
covariance.compute( 36, 18 );
covariance.compute( 40, 9 );
covariance.result();
// returns { size: 8,
//   meanX: 23.25,
//   meanY: 46.5,
//   cov: -275.8571,
//   covp: -241.375
// }
Returns:

A stream object to compute values and obtain results

Type
Stream

(static) freqTable() → {Stream}

Source:

It is a higher order function that returns a Stream

The result() returns an object containing the frequency table sorted in descending order of category counts or frequency, along with it's size, sum of all counts, x2 - chi-squared statistic, df - degree of freedom, and the entropy.

The x2 along with the df can be used test the hypothesis that "the distribution is a uniform one". The percentage in table give the percentage of a category count against the sum; and expected is the count assuming an uniform distribution.

Example
var ft = freqTable();
ft.build( 'Tea' );
ft.build( 'Tea' );
ft.build( 'Tea' );
ft.build( 'Pepsi' );
ft.build( 'Pepsi' );
ft.build( 'Gin' );
ft.build( 'Coke' );
ft.build( 'Coke' );
ft.value();
// returns { Tea: 3, Pepsi: 2, Gin: 1, Coke: 2 }
ft.result();
// returns {
//  table: [
//   { category: 'Tea', observed: 3, percentage: 37.5, expected: 2 },
//   { category: 'Pepsi', observed: 2, percentage: 25, expected: 2 },
//   { category: 'Coke', observed: 2, percentage: 25, expected: 2 },
//   { category: 'Gin', observed: 1, percentage: 12.5, expected: 2 }
//  ],
//  size: 4,
//  sum: 8,
//  x2: 1,
//  df: 3,
//  entropy: 1.9056
// }
Returns:

A stream object to compute values and obtain results

Type
Stream

(static) max() → {Stream}

Source:

It is a higher order function that returns a Stream.

The result() returns an object containing max.

Example
var maximum = max();
maximum.compute( 3 );
maximum.compute( 6 );
maximum.value();
// returns 6
maximum.result();
// returns { max: 6 }
Returns:

A stream object to compute values and obtain results

Type
Stream

(static) mean() → {Stream}

Source:

It is a higher order function that returns a Stream.

The computations are inspired by the method proposed by B. P. Welford.

The result() returns an object containing sample mean along with size of data.

Example
var avg = mean();
avg.compute( 2 );
avg.compute( 3 );
avg.compute( 5 );
avg.compute( 7 );
avg.value();
// returns 4.25
avg.result();
// returns { n: 4, mean: 4.25 }
Returns:

A stream object to compute values and obtain results

Type
Stream

(static) min() → {Stream}

Source:

It is a higher order function that returns a Stream.

The result() returns an object containing min.

Example
var minimum = min();
minimum.compute( 3 );
minimum.compute( 6 );
minimum.value();
// returns 3
minimum.result();
// returns { min: 3 }
Returns:

A stream object to compute values and obtain results

Type
Stream

(static) simpleLinearRegression() → {Stream}

Source:

Simple Linear Regression — slr is a higher order function that returns a Stream.

The correlation is an object containing slope, intercept, r, r2, se along with the size of data i.e. number of x & y pairs. In case of any error such as no input data or zero variance, correlation object will be an empty one.

Example
var regression = simpleLinearRegression();
regression.compute( 10, 80 );
regression.compute( 15, 75 );
regression.compute( 16, 65 );
regression.compute( 18, 50 );
regression.compute( 21, 45 );
regression.compute( 30, 30 );
regression.compute( 36, 18 );
regression.compute( 40, 9 );
regression.result();
// returns { slope: -2.3621,
//   intercept: 101.4188,
//   r: -0.9766,
//   r2: 0.9537,
//   se: 5.624,
//   size: 8
// }
Returns:

A stream object to compute values and obtain results

Type
Stream

(static) stdev() → {Stream}

Source:

It is a higher order function that returns a Stream.

The computations are inspired by the method proposed by B. P. Welford.

The result() returns an object containing sample stdev and variance, along with mean, size of data; it also contains population standard deviation and variance as stdevp and variancep.

Example
var sd = stdev();
sd.compute( 2 );
sd.compute( 3 );
sd.compute( 5 );
sd.compute( 7 );
sd.value();
// returns 2.2174
sd.result();
// returns { size: 4, mean: 4.25,
//   variance:  4.9167,
//   stdev: 2.2174,
//   variancep: 3.6875,
//   stdevp: 1.9203
// }
Returns:

A stream object to compute values and obtain results

Type
Stream

(static) sum() → {Stream}

Source:

It is a higher order function that returns a Stream.

The result() returns an object containing sum.

Example
var addition = sum();
addition.compute( 1 );
addition.compute( 10e+100 );
addition.compute( 1 );
addition.compute( -10e+100 );
addition.value();
// returns 2
addition.result();
// returns { sum: 2 }
Returns:

A stream object to compute values and obtain results

Type
Stream

(static) summary() → {Stream}

Source:

It is a higher order function that returns a Stream.

The computations are inspired by the method proposed by B. P. Welford.

The summary statistics is an object containing size, min, mean, max, sample stdev along with sample variance of data; it also contains population standard deviation and variance as stdevp and variancep.

Example
var ss = summary();
ss.compute( 2 );
ss.compute( 3 );
ss.compute( 5 );
ss.compute( 7 );
ss.result();
// returns { size: 4, min: 2, mean: 4.25, max: 7,
//   variance: 4.9167,
//   stdev: 2.2174,
//   3.6875,
//   stdevp: 1.9203
// }
Returns:

A stream object to compute values and obtain results

Type
Stream