You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @param {number} correction - degrees of freedom adjustment
260
271
* @param {NumericArray} x - input array
261
-
* @throws {TypeError} first argument must be an number
262
-
* @throws {TypeError} second argument must be an array-like object
263
-
* @throws {TypeError} second argument must have a supported data type
272
+
* @param {number} correction - degrees of freedom adjustment
273
+
* @throws {TypeError} first argument must have a supported data type
274
+
* @throws {TypeError} first argument must be an array-like object
275
+
* @throws {TypeError} second argument must be an number
264
276
* @returns {number} standard deviation
265
277
*
266
278
* @example
267
279
* var x = [ 1.0, -2.0, 2.0 ];
268
280
*
269
-
* var v = stdev( 1, x );
281
+
* var v = stdev( x, 1.0 );
270
282
* // returns ~2.0817
271
283
*/
272
-
function stdev( correction, x ) {
284
+
function stdev( x ) {
285
+
var correction;
273
286
var dt;
274
-
if ( !isNumber( correction ) ) {
275
-
throw new TypeError( format( 'invalid argument. First argument must be an number. Value: `%s`.', correction ) );
276
-
}
277
287
if ( !isCollection( x ) ) {
278
-
throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', x ) );
288
+
throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );
279
289
}
280
290
dt = dtype( x ) || GENERIC_DTYPE;
281
291
if ( !contains( IDTYPES, dt ) ) {
282
-
throw new TypeError( format( 'invalid argument. Second argument must have one of the following data types: "%s". Data type: `%s`.', join( IDTYPES, '", "' ), dt ) );
292
+
throw new TypeError( format( 'invalid argument. First argument must have one of the following data types: "%s". Data type: `%s`.', join( IDTYPES, '", "' ), dt ) );
293
+
}
294
+
if ( arguments.length > 1 ) {
295
+
correction = arguments[ 1 ];
296
+
if ( !isNumber( correction ) ) {
297
+
throw new TypeError( format( 'invalid argument. Second argument must be a number. Value: `%s`.', correction ) );
0 commit comments