Created
October 1, 2010 03:28
-
-
Save d2fn/605676 to your computer and use it in GitHub Desktop.
partition set of numbers into subsets of equal size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def equibin(a:Seq[Double], depth:Int) = { | |
val d = a.size/depth | |
(0 until a.size) // ordered set of indexes of all values | |
.groupBy(i=>i/d).values.toList.sortBy(s=>s(0)) // split set into 'd' separate lists | |
.map { group => group.map( i => a(i) ) } // map onto value set | |
.map { values => ( (min(a),max(a)), values ) }// each bin gets min-max metadata | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment