Skip to content

Commit

Permalink
Merge pull request #60 from tushargupta51/modeFucntion
Browse files Browse the repository at this point in the history
mode function fixed
  • Loading branch information
trevnorris committed Sep 11, 2012
2 parents b4e8944 + 40b5c2d commit 55b765d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/core.js
Expand Up @@ -28,6 +28,11 @@ var slice = Array.prototype.slice,
// test if number and not NaN
isNumber = function( arg ) {
return toString.call( arg ) === '[object Number]' && !isNaN( arg );
},

// converts the jStat matrix to vector
toVector = function( arr ) {
return [].concat.apply( [], arr );
};

// global function
Expand Down Expand Up @@ -99,7 +104,8 @@ jStat.utils = {
calcRdx : calcRdx,
isArray : isArray,
isFunction : isFunction,
isNumber : isNumber
isNumber : isNumber,
toVector : toVector
};

// create method for easy extension
Expand Down
3 changes: 1 addition & 2 deletions src/vector.js
Expand Up @@ -246,8 +246,7 @@ jStat.extend({
tmpthis = fullbool === true ? this : this.transpose();
for ( ; i < tmpthis.length; i++ )
arr[i] = jStat[ passfunc ]( tmpthis[i] );

return fullbool === true ? jStat[ passfunc ]( arr ) : arr;
return fullbool === true ? jStat[ passfunc ]( jStat.utils.toVector(arr) ) : arr;
}
// pass fullbool if only vector, not a matrix. for variance and stdev
return jStat[ passfunc ]( this[0], fullbool );
Expand Down

0 comments on commit 55b765d

Please sign in to comment.