You are looking at historical revision 41403 of this page. It may differ significantly from its current revision.
micro-stats
This egg provides simple statistical operations. Very simple.
Documentation
Usage
(import micro-stats)
Types
seq
binary-predicate
statistics-alist
[type] seq : (or string vector list ...)[type] binary-predicate : (* * --> boolean)
[type] statistics-alist : (or null (list-of (pair symbol *)))
Note an seq is anything understood as a sequence by the sequences egg.
generate-statistics
[procedure] (generate-statistics SEQ [SET-ID]) -> statistics-alist- SEQ
- (seq-of real) ; SEQ of all iterations, in microseconds
- SET-ID
- symbol ; 'normal
Returns an alist with the following:
- size
- the count of the SEQ
- min
- the minimum of the SEQ
- max
- the maximum of the SEQ
- mean
- arithmetic-mean alias
- arithmetic-mean
- the arithmetic average of the SEQ
- sd
- standard-deviation alias
- sigma
- standard-deviation alias
- standard-deviation
- the standard deviation for the SEQ
When verbose adds the following:
- 95th
- the 95th percentile of the SEQ
- harmonic-mean
- the harmonic average of the SEQ
- geometric-mean
- the geometric average of the SEQ
- median
- the median of the SEQ
- mode
- the mode of the SEQ
- var
- variance alias
- sigma^2
- variance alias
- variance
- the variance for the SEQ
basic-statistics
[procedure] (basic-statistics SEQ) -> (vector-of real)Returns #(m h g s v) for the SEQ.
- SEQ
- (seq-of real) ; the sample
generate-statistics-alist
[procedure] (generate-statistics-alist SEQ FUNCS [BASICS]) -> statistics-alistReturns an alist for a set of statistical functions results.
- SEQ
- (seq-of real) ; the sample
- FUNCS
- (list-of function-spec); the report template
- BASICS
- #(m h g s v) ; required statistics
A function-spec is:
- size
- sample count
- min
- sample minimum
- max
- sample maximum
- arithmetic-mean
- sample arithmetic-average
- standard-deviation
- sample standard-deviation
- percentile
- sample Pth-percentile ; default is 95
- harmonic-mean
- sample harmonic-average
- geometric-mean
- sample geometric-average
- median
- sample median
- mode
- sample mode
- variance
- sample variance
- (KEY . (F [PARAM ...]))
- sample parameterized (: F function-spec)
percentile
[procedure] (percentile SEQ [P]) -> realReturns Pth percentile of SEQ.
- SEQ
- (seq-of real)
- P
- [0 .. 100] ; defaults is 95
arithmetic-mean
[procedure] (arithmeticmean SEQ) -> realReturns the arithmetic mean for SEQ.
- SEQ
- (seq-of real)
mean
[procedure] (mean SEQ) -> real real realReturns the arithmetic, harmonic, & geometric means for SEQ.
- SEQ
- (seq-of real)
median
[procedure] (median SEQ [<?]) -> realReturns the median of the SEQ.
- SEQ
- (seq-of real)
- <?
- binary-predicate ; less-than predicate, default <
mode
[procedure] (mode SEQ [=?]) -> realReturns the mode of the SEQ.
- SEQ
- (seq-of real)
- =?
- binary-predicate ; equality predicate, default =
variance
[procedure] (variance SEQ MEAN) -> realReturns the variance for SEQ, given the MEAN.
standard-deviation
[procedure] (standard-deviation SEQ [MEAN]) -> real realReturns the standard-deviation, & variance for SEQ, given the MEAN. Calculates the MEAN when not given.
- SEQ
- (seq-of real)
- MEAN
- real
seq-utils
Usage
(import seq-utils) ;but suggest (import (prefix seq-utils seq:))
->list
->vector
->string
[procedure] (->list SEQ) --> vector[procedure] (->vector SEQ) --> vector
[procedure] (->string SEQ) --> string
Coerce SEQ to the named sequence type, unless an instance.
- SEQ
- sequence ; sequence to coerce.
merge!
[procedure] (merge! SEQ-A SEQ-B <?) -> sequence- SEQ-A SEQ-B
- sequence sequence ; sequences to merge.
- <?
- binary-predicate ; less-than predicate.
Return sequence is coerced to the same type as SEQA.
merge
[procedure] (merge SEQ-A SEQ-B <?) --> sequence- SEQ-A SEQ-B
- sequence sequence ; sequences to merge.
- <?
- binary-predicate ; less-than predicate.
Return sequence is coerced to the same type as SEQA.
sorted?
[procedure] (sorted? SEQ <?) --> boolean- SEQ
- sequence ; sequence to test.
- <?
- binary-predicate ; less-than predicate.
sort!
[procedure] (sort! SEQ <?) -> sequence- SEQ
- sequence ; sequence to sort.
- <?
- binary-predicate ; less-than predicate.
Return sequence is coerced to the same type as SEQ.
sort
[procedure] (sort SEQ <?) --> sequence- SEQ
- sequence ; sequence to sort.
- <?
- binary-predicate ; less-than predicate.
Return sequence is coerced to the same type as SEQ.
histogram
[procedure] (histogram SEQ [=?]) --> alistReturns an (list-of ('a . integer)) where SEQ is (sequence-of 'a).
- SEQ
- sequence ; sequence to count element by element.
- =?
- binary-predicate ; equality predicate, default is equal?.
unfold-alist
[procedure] (unfold-alist SEQ NEXT SEED [=?]) --> alist- SEQ
- sequence ; sequence to unfold.
- NEXT
- (KEY 'a -> 'a) ; next for KEY & previous, or initial, value.
- SEED
- 'a ; initial value.
- =?
- binary-predicate ; equality predicate, default is equal?.
Requirements
Authors
Repository
This egg is hosted on the CHICKEN Subversion repository:
https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/micro-stats
If you want to check out the source code repository of this egg and you are not familiar with Subversion, see this page.
Version history
- 0.0.8
- Add coercions. Better types. More tests.
- 0.0.7
- Export arithmetic-mean & variance.
- 0.0.3
- Missing dependency. Fix percentile side-effecting.
- 0.0.2
- Fix category.
- 0.0.1
- C5 release.
License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A full copy of the GPL license can be found at <http://www.gnu.org/licenses/>.