Skip to content
65 changes: 20 additions & 45 deletions lib/node_modules/@stdlib/stats/ztest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,18 @@ var ztest = require( '@stdlib/stats/ztest' );
The function performs a one-sample z-test for the null hypothesis that the data in [array][mdn-array] or [typed array][mdn-typed-array] `x` is drawn from a normal distribution with mean zero and known standard deviation `sigma`.

```javascript
var normal = require( '@stdlib/random/base/normal' ).factory;
var normal = require( '@stdlib/random/array/normal' );

var rnorm = normal( 0.0, 2.0, {
'seed': 5776
});

var arr = new Array( 300 );
var i;
for ( i = 0; i < arr.length; i++ ) {
arr[ i ] = rnorm();
}
// Create an array of random numbers:
var arr = normal( 300, 0.0, 2.0 );

// Test whether true mean is equal to 2.0:
var out = ztest( arr, 2.0 );
/* e.g., returns
{
'rejected': false,
'pValue': ~0.155,
'statistic': -1.422,
'statistic': ~-1.422,
'ci': [~-0.391,~0.062],
// ...
}
Expand Down Expand Up @@ -90,16 +84,13 @@ The `ztest` function accepts the following `options`:
By default, the hypothesis test is carried out at a significance level of `0.05`. To choose a different significance level, set the `alpha` option.

```javascript
var table;
var out;
var arr;
var arr = [ 2, 4, 3, 1, 0 ];

arr = [ 2, 4, 3, 1, 0 ];

out = ztest( arr, 2.0, {
var out = ztest( arr, 2.0, {
'alpha': 0.01
});
table = out.print();

var table = out.print();
/* e.g., returns
One-sample z-test

Expand Down Expand Up @@ -132,12 +123,9 @@ table = out.print();
To test whether the data comes from a distribution with a mean different than zero, set the `mu` option.

```javascript
var out;
var arr;

arr = [ 4, 4, 6, 6, 5 ];
var arr = [ 4, 4, 6, 6, 5 ];

out = ztest( arr, 1.0, {
var out = ztest( arr, 1.0, {
'mu': 5.0
});
/* e.g., returns
Expand All @@ -154,16 +142,13 @@ out = ztest( arr, 1.0, {
By default, a two-sided test is performed. To perform either of the one-sided tests, set the `alternative` option to `less` or `greater`.

```javascript
var table;
var out;
var arr;

arr = [ 4, 4, 6, 6, 5 ];
var arr = [ 4, 4, 6, 6, 5 ];

out = ztest( arr, 1.0, {
var out = ztest( arr, 1.0, {
'alternative': 'less'
});
table = out.print();

var table = out.print();
/* e.g., returns
One-sample z-test

Expand Down Expand Up @@ -204,24 +189,14 @@ table = out.print();
<!-- eslint no-undef: "error" -->

```javascript
var normal = require( '@stdlib/random/base/normal' ).factory;
var normal = require( '@stdlib/random/array/normal' );
var ztest = require( '@stdlib/stats/ztest' );

var rnorm;
var arr;
var out;
var i;

rnorm = normal( 5.0, 4.0, {
'seed': 37827
});
arr = new Array( 500 );
for ( i = 0; i < arr.length; i++ ) {
arr[ i ] = rnorm();
}
// Create an array of random numbers:
var arr = normal( 500, 5.0, 4.0 );

// Test whether true mean is equal to zero:
out = ztest( arr, 4.0 );
// Test whether true mean is equal to 4.0:
var out = ztest( arr, 4.0 );
console.log( out.print() );
/* e.g., =>
One-sample z-test
Expand Down
20 changes: 5 additions & 15 deletions lib/node_modules/@stdlib/stats/ztest/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,14 @@

'use strict';

var normal = require( '@stdlib/random/base/normal' ).factory;
var normal = require( '@stdlib/random/array/normal' );
var ztest = require( './../lib' );

var rnorm;
var arr;
var out;
var i;
// Create an array of random numbers:
var arr = normal( 500, 5.0, 4.0 );

rnorm = normal( 5.0, 4.0, {
'seed': 37827
});
arr = new Array( 500 );
for ( i = 0; i < arr.length; i++ ) {
arr[ i ] = rnorm();
}

// Test whether true mean is equal to zero:
out = ztest( arr, 4.0 );
// Test whether true mean is equal to 4.0:
var out = ztest( arr, 4.0 );
console.log( out.print() );

// Test whether true mean is equal to five:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var getOwnPropertyNames = require( '@stdlib/utils/property-names' );
var getPrototypeOf = require( '@stdlib/utils/get-prototype-of' );
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
var isNonEnumerable = require( '@stdlib/assert/is-nonenumerable-property' );
var Object = require( '@stdlib/object/ctor' );


// MAIN //
Expand Down