/* eslint-disable no-invalid-this */

/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Compute a two-sample z-Test.
*
* @module @stdlib/stats/ztest2
*
* @example
* var ztest2 = require( '@stdlib/stats/ztest2' );
* var incrspace = require( '@stdlib/math/utils/incrspace' );
*
* var a = incrspace( 1, 11, 1 );
* var b = incrspace( 7, 21, 1 );
*
* var out = ztest2( a, b );
* var table = out.print();
*/

/**
* Computes a two-sample z-test.
*
* @param {NumericArray} x - first data array
* @param {NumericArray} y - second data array
* @param {PositiveNumber} sigmax - known standard deviation of first group
* @param {PositiveNumber} sigmay - known standard deviation of second group
* @param {Options} [options] - function options
* @param {number} [options.alpha=0.05] - significance level
* @param {string} [options.alternative='two-sided'] - alternative hypothesis (`two-sided`, `less` or `greater`)
* @param {number} [options.difference=0] - difference in means under H0
* @throws {TypeError} x argument has to be a typed array or array of numbers
* @throws {TypeError} y argument has to be a typed array or array of numbers
* @throws {TypeError} sigmax argument has to be a positive number
* @throws {TypeError} sigmay argument has to be a positive number
* @throws {TypeError} options has to be simple object
* @throws {TypeError} must provide valid options
* @throws {Error} `alternative` option  must be either `two-sided`, `less`, or `greater`
* @returns {Object} test result object
*/

/**
* Pretty-print output of test.
*
* @param {Object} [opts] - options object
* @param {PositiveInteger} [opts.digits=4] - number of digits after the decimal point
* @param {boolean} [opts.decision=true] - boolean indicating whether to print the test decision
* @throws {TypeError} options argument must be an object
* @throws {TypeError} must provide valid options
* @returns {string} formatted output
*/

/**
* Split values into two groups according to a predicate function.
*
* @module @stdlib/utils/bifurcate-by
*
* @example
* var bifurcateBy = require( '@stdlib/utils/bifurcate-by' );
*
* function predicate( v ) {
*     return v[ 0 ] === 'b';
* }
* var arr = [ 'beep', 'boop', 'foo', 'bar' ];
*
* var out = bifurcateBy( arr, predicate );
* // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ]
*
* @example
* var bifurcateBy = require( '@stdlib/utils/bifurcate-by' );
*
* function predicate( v ) {
*     return v[ 0 ] === 'b';
* }
* var arr = [ 'beep', 'boop', 'foo', 'bar' ];
*
* var opts = {
*     'returns': 'indices'
* };
* var out = bifurcateBy( arr, opts, predicate );
* // returns [ [ 0, 1, 3 ], [ 2 ] ]
*
* @example
* var bifurcateBy = require( '@stdlib/utils/bifurcate-by' );
*
* function predicate( v ) {
*     return v[ 0 ] === 'b';
* }
* var arr = [ 'beep', 'boop', 'foo', 'bar' ];
*
* var opts = {
*     'returns': '*'
* };
* var out = bifurcateBy( arr, opts, predicate );
* // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ]
*/

/**
* Splits values into two groups according to a predicate function and outputs results as element indices.
*
* @private
* @param {Collection} collection - input collection
* @param {Options} opts - function options
* @param {*} [opts.thisArg] - execution context
* @param {Function} predicate - predicate function specifying which group an element in the input collection belongs to
* @returns {(Array<Array>|Array)} results
*
* @example
* function predicate( v ) {
*     return v[ 0 ] === 'b';
* }
* var arr = [ 'beep', 'boop', 'foo', 'bar' ];
*
* var out = bifurcateBy( arr, {}, predicate );
* // returns [ [ 0, 1, 3 ], [ 2 ] ]
*/

/**
* Splits values into two groups according to a predicate function and outputs results as element values.
*
* ## Notes
*
* -   We need to cache the collection value to prevent the edge case where, during the invocation of the predicate function, the element at index `i` is swapped for some other value. For some, that might be a feature; here, we take the stance that one should be less clever.
*
*
* @private
* @param {Collection} collection - input collection
* @param {Options} opts - function options
* @param {*} [opts.thisArg] - execution context
* @param {Function} predicate - predicate function indicating which group an element in the input collection belongs to
* @returns {(Array<Array>|Array)} results
*
* @example
* function predicate( v ) {
*     return v[ 0 ] === 'b';
* }
* var arr = [ 'beep', 'boop', 'foo', 'bar' ];
*
* var out = bifurcateBy( arr, {}, predicate );
* // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ]
*/

/**
* Splits values into two groups according to a predicate function and outputs results as index-element values.
*
* ## Notes
*
* -   We need to cache the collection value to prevent the edge case where, during the invocation of the predicate function, the element at index `i` is swapped for some other value. For some, that might be a feature; here, we take the stance that one should be less clever.
*
*
* @private
* @param {Collection} collection - input collection
* @param {Options} opts - function options
* @param {*} [opts.thisArg] - execution context
* @param {Function} predicate - predicate function indicating which group an element in the input collection belongs to
* @returns {(Array<Array>|Array)} results
*
* @example
* function predicate( v ) {
*     return v[ 0 ] === 'b';
* }
* var arr = [ 'beep', 'boop', 'foo', 'bar' ];
*
* var out = bifurcateBy( arr, {}, predicate );
* // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ]
*/

/**
* Splits values into two groups according to a predicate function.
*
* @param {Collection} collection - input collection
* @param {Options} [options] - function options
* @param {*} [options.thisArg] - execution context
* @param {string} [options.returns="values"] - if `values`, values are returned; if `indices`, indices are returned; if `*`, both indices and values are returned
* @param {Function} predicate - predicate function indicating which group an element in the input collection belongs to
* @throws {TypeError} first argument must be a collection
* @throws {TypeError} options argument must be an object
* @throws {TypeError} last argument must be a function
* @throws {TypeError} must provide valid options
* @returns {(Array<Array>|Array)} group results
*
* @example
* function predicate( v ) {
*     return v[ 0 ] === 'b';
* }
* var arr = [ 'beep', 'boop', 'foo', 'bar' ];
*
* var out = bifurcateBy( arr, predicate );
* // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ]
*
* @example
* function predicate( v ) {
*     return v[ 0 ] === 'b';
* }
* var arr = [ 'beep', 'boop', 'foo', 'bar' ];
*
* var opts = {
*     'returns': 'indices'
* };
* var out = bifurcateBy( arr, opts, predicate );
* // returns [ [ 0, 1, 3 ], [ 2 ] ]
*
* @example
* function predicate( v ) {
*     return v[ 0 ] === 'b';
* }
* var arr = [ 'beep', 'boop', 'foo', 'bar' ];
*
* var opts = {
*     'returns': '*'
* };
* var out = bifurcateBy( arr, opts, predicate );
* // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ]
*/

/**
* Test if a value is a probability.
*
* @module @stdlib/assert/is-probability
*
* @example
* var isProbability = require( '@stdlib/assert/is-probability' );
*
* var bool = isProbability( 0.5 );
* // returns true
*
* bool = isProbability( new Number( 0.5 ) );
* // returns true
*
* bool = isProbability( 3.14 );
* // returns false
*
* bool = isProbability( -5.0 );
* // returns false
*
* bool = isProbability( null );
* // returns false
*
* @example
* var isProbability = require( '@stdlib/assert/is-probability' ).isPrimitive;
*
* var bool = isProbability( 0.3 );
* // returns true
*
* bool = isProbability( new Number( 0.3 ) );
* // returns false
*
* @example
* var isProbability = require( '@stdlib/assert/is-probability' ).isObject;
*
* var bool = isProbability( 0.77 );
* // returns false
*
* bool = isProbability( new Number( 0.77 ) );
* // returns true
*/

/**
* Tests if a value is a number object having a value which is a probability.
*
* @param {*} value - value to test
* @returns {boolean} boolean indicating if a value is a number object having a value which is a probability
*
* @example
* var bool = isProbability( 0.5 );
* // returns false
*
* @example
* var bool = isProbability( new Number( 0.5 ) );
* // returns true
*/

/**
* Tests if a value is a number primitive having a value which is a probability.
*
* @param {*} value - value to test
* @returns {boolean} boolean indicating if a value is a number primitive having a value which is a probability
*
* @example
* var bool = isProbability( 0.66 );
* // returns true
*
* @example
* var bool = isProbability( new Number( 0.66 ) );
* // returns false
*/

/**
* Tests if a value is a probability.
*
* @param {*} value - value to test
* @returns {boolean} boolean indicating whether value is a probability
*
* @example
* var bool = isProbability( 0.5 );
* // returns true
*
* @example
* var bool = isProbability( new Number( 0.5 ) );
* // returns true
*
* @example
* var bool = isProbability( 3.14 );
* // returns false
*
* @example
* var bool = isProbability( -5.0 );
* // returns false
*
* @example
* var bool = isProbability( null );
* // returns false
*/

/**
* Validates function options.
*
* @private
* @param {Object} opts - destination for validated options
* @param {Options} options - function options
* @param {number} [options.alpha] - significance level
* @param {string} [options.alternative] - alternative hypothesis (`two-sided`, `less` or `greater`)
* @param {number} [options.difference] - difference in means under H0
* @returns {(null|Error)} null or an error
*/

/**
* Validates function options.
*
* @private
* @param {Object} opts - destination object
* @param {Options} options - function options
* @param {*} [options.thisArg] - execution context
* @param {string} [options.returns] - output format
* @returns {(Error|null)} null or an error object
*
* @example
* var opts = {};
* var options = {
*     'returns': '*',
*     'thisArg': {}
* };
* var err = validate( opts, options );
* if ( err ) {
*     throw err;
* }
*/

/***/

// EXPORTS //

// MAIN //

// MODULES //

// eslint-disable-line stdlib/no-redeclare
