math.statistics, add docs for cum-sum0, add cum-product1 for symmetry
parent
13c27b69e5
commit
43be523e31
|
@ -188,6 +188,16 @@ HELP: cum-sum
|
|||
}
|
||||
} ;
|
||||
|
||||
HELP: cum-sum0
|
||||
{ $values { "seq" sequence } { "seq'" sequence } }
|
||||
{ $description "Returns the cumulative sum of " { $snippet "seq" } " starting with 0 and not including the whole sum." }
|
||||
{ $examples
|
||||
{ $example "USING: math.statistics prettyprint ;"
|
||||
"{ 1 -1 2 -1 4 } cum-sum0 ."
|
||||
"{ 0 1 0 2 1 }"
|
||||
}
|
||||
} ;
|
||||
|
||||
HELP: cum-count
|
||||
{ $values { "seq" sequence } { "quot" quotation } { "seq'" sequence } }
|
||||
{ $description "Returns the cumulative count of how many times " { $snippet "quot" } " returns true." }
|
||||
|
@ -209,6 +219,16 @@ HELP: cum-product
|
|||
}
|
||||
} ;
|
||||
|
||||
HELP: cum-product1
|
||||
{ $values { "seq" sequence } { "seq'" sequence } }
|
||||
{ $description "Returns the cumulative product of " { $snippet "seq" } " starting with 1 and not including the whole product." }
|
||||
{ $examples
|
||||
{ $example "USING: math.statistics prettyprint ;"
|
||||
"{ 2 3 4 } cum-product1 ."
|
||||
"{ 1 2 6 }"
|
||||
}
|
||||
} ;
|
||||
|
||||
HELP: cum-mean
|
||||
{ $values { "seq" sequence } { "seq'" sequence } }
|
||||
{ $description "Returns the cumulative mean of " { $snippet "seq" } "." }
|
||||
|
@ -309,6 +329,7 @@ $nl
|
|||
cum-sum
|
||||
cum-sum0
|
||||
cum-product
|
||||
cum-product1
|
||||
}
|
||||
"Cumulative comparisons:"
|
||||
{ $subsections
|
||||
|
|
|
@ -212,6 +212,9 @@ IN: math.statistics.tests
|
|||
{ { 0 1 3 6 } }
|
||||
[ { 1 2 3 4 } cum-sum0 ] unit-test
|
||||
|
||||
{ { 1 2 6 } }
|
||||
[ { 2 3 4 } cum-product1 ] unit-test
|
||||
|
||||
{
|
||||
H{
|
||||
{ 0 V{ 600 603 606 609 } }
|
||||
|
|
|
@ -349,6 +349,9 @@ ALIAS: std sample-std
|
|||
: cum-product ( seq -- seq' )
|
||||
1 [ * ] accumulate* ;
|
||||
|
||||
: cum-product1 ( seq -- seq' )
|
||||
1 [ * ] accumulate nip ;
|
||||
|
||||
: cum-mean ( seq -- seq' )
|
||||
0 swap [ [ + dup ] dip 1 + / ] map-index nip ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue