Basic statistical computations on frequency maps. A frequency map (freq-map) is a map from observed values to their frequency in a data set.
If the observed values are all integers within a small range, then a frequency map may be exact, such as that returned by clojure.core/frequencies. Floating-point values or a large range of integers can be grouped into 'buckets' as in a histogram: the 'bucket-frequencies' function does this.
You can create your own bucketed frequency map (for example, as part of a larger 'reduce' operation) using the functions 'bucket' and 'recover-bucket-keys'.
Basic statistical computations on frequency maps. A frequency map (freq-map) is a map from observed values to their frequency in a data set. If the observed values are all integers within a small range, then a frequency map may be exact, such as that returned by clojure.core/frequencies. Floating-point values or a large range of integers can be grouped into 'buckets' as in a histogram: the 'bucket-frequencies' function does this. You can create your own bucketed frequency map (for example, as part of a larger 'reduce' operation) using the functions 'bucket' and 'recover-bucket-keys'.
(bucket bucket-size value)
Returns an integer bucket ID for the observed value. Bucket maps use integers as map keys to avoid possible errors from floating-point arithmetic.
Returns an integer bucket ID for the observed value. Bucket maps use integers as map keys to avoid possible errors from floating-point arithmetic.
(bucket-frequencies bucket-size values)
Returns a bucketed frequency map. Keys in the map are values from the input, rounded up to bucket-size. Values in the map are counts of the number of occurances of values less than or equal to their bucket key but greater than the next-lowest bucket key.
Returns a bucketed frequency map. Keys in the map are values from the input, rounded up to bucket-size. Values in the map are counts of the number of occurances of values less than or equal to their bucket key but greater than the next-lowest bucket key.
(mean freq-map)
Returns the mean (average) of observed values in a frequency map.
Returns the mean (average) of observed values in a frequency map.
(median freq-map)
Returns the median of the observed values in the frequency map.
Returns the median of the observed values in the frequency map.
(percentiles freq-map percentiles)
Returns a map of percentile values from the frequency map. Argument 'percentiles' is a collection of percentile targets, which will be keys in the returned map. For example, a percentiles argument of [25 50 99.9] would return a map containing the 25th, 50th (median), and 99.9th percentile.
Returns a map of percentile values from the frequency map. Argument 'percentiles' is a collection of percentile targets, which will be keys in the returned map. For example, a percentiles argument of [25 50 99.9] would return a map containing the 25th, 50th (median), and 99.9th percentile.
(percentiles* sorted-freq-map percentiles sample-count)
Like percentiles but the sample-count is provided as an argument instead of computed, and the frequency map must already be sorted.
Like percentiles but the sample-count is provided as an argument instead of computed, and the frequency map must already be sorted.
(quantile freq-map k q)
Returns the value which is greater than k/q of the observed values in the frequency map. For example, k=1 q=2 is the median; k=99 q=100 is the 99th percentile. For bucketed frequency maps, returns the nearest bucket.
Returns the value which is greater than k/q of the observed values in the frequency map. For example, k=1 q=2 is the median; k=99 q=100 is the 99th percentile. For bucketed frequency maps, returns the nearest bucket.
(quantile* sorted-freq-map k q sample-count)
Like quantile but takes sample-count as an argument. For when you already know the sample-count and don't want to recompute it. Also assumes that the frequency map is already sorted.
Like quantile but takes sample-count as an argument. For when you already know the sample-count and don't want to recompute it. Also assumes that the frequency map is already sorted.
(recover-bucket-keys bucket-map bucket-size)
Converts the keys of a map from integer bucket IDs to the original value domain. Use this only if you are building up a bucket map yourself with the 'bucket' function; the bucket-frequencies function calls recover-keys automatically.
Converts the keys of a map from integer bucket IDs to the original value domain. Use this only if you are building up a bucket map yourself with the 'bucket' function; the bucket-frequencies function calls recover-keys automatically.
(sample-count freq-map)
Returns the number of observed values in a frequency map.
Returns the number of observed values in a frequency map.
(stats freq-map
&
{:keys [percentiles] :or {percentiles [25 50 75 90 95 99 99.9]}})
Returns a map of statistics for the frequency map with the following keys:
:mean, :median, :variance, :stdev, :sum, :sample-count,
:min minimum observed value;
:max maximum observed value;
:percentiles Map of percentile level to observed value. Defaults to quartiles and 90, 95, 99, and 99.9th percentiles. Change the returned percentiles by passing a vector of percentile levels (between 0 and 100) as the option :percentiles.
Returns a map of statistics for the frequency map with the following keys: :mean, :median, :variance, :stdev, :sum, :sample-count, :min minimum observed value; :max maximum observed value; :percentiles Map of percentile level to observed value. Defaults to quartiles and 90, 95, 99, and 99.9th percentiles. Change the returned percentiles by passing a vector of percentile levels (between 0 and 100) as the option :percentiles.
(stdev freq-map)
Returns the standard deviation (square root of the variance) of observed values in a frequency map.
Returns the standard deviation (square root of the variance) of observed values in a frequency map.
(sum freq-map)
Returns the sum of all observed values in a frequency map.
Returns the sum of all observed values in a frequency map.
(values freq-map)
Returns a lazy sequence of all the observed values, repeating each value the number of times it was observed.
Returns a lazy sequence of all the observed values, repeating each value the number of times it was observed.
(variance freq-map)
Returns the variance of observed values in a frequency map.
Returns the variance of observed values in a frequency map.
(variance* freq-map mean sample-count)
Like 'variance' but takes the mean and sample count as arguments instead of computing them.
Like 'variance' but takes the mean and sample count as arguments instead of computing them.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close