nl_tokens: NORMAL RANDOM VARIATES // FUNCTION : random ( [ dims ] [ opts ] ) Creates a matrix or array filled with normal random numbers .
pl_tokens: function random ( dims , options ) { var opts = { } ; var isArray ; var ndims ; var err ; var len ; var mu ; var sigma ; var rand ; var dt ; if ( arguments . length > 0 ) { isArray = isPositiveIntegerArray ( dims ) ; if ( ! isArray && ! isPositiveInteger ( dims ) ) { throw new TypeError ( 'invalid input argument. Dimensions argument must be either a positive integer or a positive integer array. Value: `' + dims + '`.' ) ; } } if ( arguments . length > 1 ) { err = validate ( opts , options ) ; if ( err ) { throw err ; } } if ( opts . seed ) { rand = lcg ( opts . seed ) ; } else { rand = RAND ; } dt = opts . dtype || 'generic' ; mu = typeof opts . mu !== 'undefined' ? opts . mu : 0 ; sigma = typeof opts . sigma !== 'undefined' ? opts . sigma : 1 ; if ( arguments . length === 0 ) { return number ( mu , sigma , rand ) ; } if ( isArray ) { ndims = dims . length ; if ( ndims < 2 ) { len = dims [ 0 ] ; } } else { ndims = 1 ; len = dims ; } // 1-dimensional data structures... if ( ndims === 1 ) { if ( len === 1 ) { return number ( mu , sigma , rand ) ; } if ( dt === 'generic' ) { return array ( len , mu , sigma , rand ) ; } return typedarray ( len , dt , mu , sigma , rand ) ; } // Multidimensional data structures... if ( dt !== 'generic' ) { if ( ndims === 2 ) { return matrix ( dims , dt , mu , sigma , <mask> ) ; } // TODO: dstructs-ndarray support goes here. Until then, fall through to plain arrays... } return arrayarray ( dims , mu , sigma , rand ) ; }