math.statistics: adding a normalized-histogram word.
parent
6072e58db3
commit
7fb8db2e74
|
@ -77,6 +77,9 @@ IN: math.statistics.tests
|
|||
"aabbcc" histogram
|
||||
] unit-test
|
||||
|
||||
{ H{ { 1 1/2 } { 2 1/6 } { 3 1/3 } } }
|
||||
[ { 1 1 1 1 1 1 2 2 3 3 3 3 } normalized-histogram ] unit-test
|
||||
|
||||
{
|
||||
V{ 0 3 6 9 }
|
||||
V{ 1 4 7 }
|
||||
|
|
|
@ -227,6 +227,9 @@ PRIVATE>
|
|||
: sorted-histogram ( seq -- alist )
|
||||
histogram sort-values ;
|
||||
|
||||
: normalized-histogram ( seq -- alist )
|
||||
[ histogram ] [ length ] bi '[ _ / ] assoc-map ;
|
||||
|
||||
: collect-pairs ( seq quot: ( x -- v k ) -- hashtable )
|
||||
[ push-at ] sequence>hashtable ; inline
|
||||
|
||||
|
|
Loading…
Reference in New Issue