package codex
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=bc7266a140c6886add673ede90e335d3
sha512=8da42c0ff2c1098c5f9cb2b5b43b306faf7ac93b8f5ae00c176918cee761f249ff45b29309f31a05bbcf6312304f86a0d5a000eb3f1094d3d3c2b9b4c7f5c386
doc/codex.stats/Stats/index.html
Module StatsSource
Compute various statistical indicators for a collection of values
Stats for a collection of type 'a, either int or float.
If 'kind is exhaustive, then this contains all values, and can compute the median, q1 and q3 (computing these requires sorting, but it is only done once, however, adding new values will require resorting).
Otherwise, when 'kind is compact, this is a constant sized aggregate. It does not store all the values, only the minimal required to compute some stats (min, max, sum, sum of squares). It can't compute the median or quartiles.
Constuctors
Convert an int collection to a float collection
Convert an exhaustive collection into a compact representation
Compact values
While empty constructors are provided, accessing stats of empty will raise CollectionTooShort. List and array constructors are linear in the size of the given list/array.
Exhaustive values
Adding values
Add a new value to the collection. Constant time operation.
Concatenate both collections. Constant time operation.
Add all values in the list, equivalent to List.fold_left add_value, linear in the size of the list for compact values, O(n log n) (in size of list+collection) for exhaustive
Add all values in the array, equivalent to Array.fold_left add_value, linear in the size of the array for compact values, O(n log n) (in size of array+collection) for exhaustive
Accessors
All accessors are constant time operations, except median, q1 and q3, which need to sort the collection. Sorting is only done once and then saved, so getting the q1 after computing the median is constant time.
The sum of the squares of the collection: \sum_i x_i^2. May raise Z.Overflow.
The average/mean value: i.e. sum collection / size collection.
The variance: i.e. sum of the squares of the difference with the average \sum_i (x_i - \mu)^2
The median, or 2nd quartile
The first quartile, requires size >= 4
The third quartile, requires size >= 4
Export values
Export the list/array of values, sorted in increasing order. If unsorted, these will sort the collection (O(n log n)), else they will copy it O(n).
Pretty printers
Both of these take an extra unit parameter to mark the end of the optional arguments.
val pp_percent :
?justify:bool ->
?precision:int ->
unit ->
Format.formatter ->
(int * int) ->
unitpp_percent () fmt (num, denom) prints the ratio num / denom as a percentage, including a final "%" symbol. Rounds fractions, so "20.99%" is printed as "21.0%" when precision is 1.
Standard SI unit prefix list: ""; "k"; "M"; "G"; "T"; "P"; "E"; "Z"; "Y"; "R"; "Q".
val pp_with_unit :
?justify:bool ->
?unit_prefixes:string list ->
?separator:string ->
?base:int ->
unit ->
Format.formatter ->
int ->
unitpp_with_unit () fmt nb prints the number nb with at most three digits using the specified unit prefixes. For example:
pp_unit fmt 123->"123"pp_unit fmt 12345->"12.3k"pp_unit fmt 123456789->"123M"
Multi-session loggers
Save stats between mutliple codex runs. Each logger saves a mapping string -> stat between various runs.