Skip to content

Commit

Permalink
Merge f9c2233 into c34c4f9
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcw committed Aug 18, 2014
2 parents c34c4f9 + f9c2233 commit 55916f0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/simple_statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,23 @@
return output;
}

// # partition
//
function partition(sample, chunks) {

// `chunks` must be zero or higher - we can't partition a non-zero
// list into zero parts.
// So, we'll detect and return null in that case to indicate
// invalid input.
if (chunks <= 0) {
return null;
}

var chunkSize = Math.ceil(sample.length / chunks);

return chunk(sample, chunkSize);
}

// # quantile
//
// This is a population quantile, since we assume to know the entire
Expand Down Expand Up @@ -1410,6 +1427,7 @@
ss.mad = mad;

ss.chunk = chunk;
ss.partition = partition;

ss.sample_covariance = sample_covariance;
ss.sample_correlation = sample_correlation;
Expand Down

0 comments on commit 55916f0

Please sign in to comment.