* [0; size) [size; 2 * size) ... [(num_buckets - 1) * size; infinity)
* @param num_buckets - number of buckets. Should be greater than 0
* @param size - size of each bucket. Should be greater than 0
- * @return pointer to a new distribution or null pointer if parameters are wrong or memory allocation fails
+ * @return - pointer to a new distribution or null pointer if parameters are wrong or memory allocation fails
*/
distribution_t* distribution_new_linear(size_t num_buckets, double size);
* @param num_buckets - number of buckets. Should be greater than 0
* @param initial_size - size of the first bucket. Should be greater than 0
* @param factor - factor for buckets' upper bound. Should be greater than 1
- * @return pointer to a new distribution or null pointer if parameters are wrong or memory allocation fails
+ * @return - pointer to a new distribution or null pointer if parameters are wrong or memory allocation fails
*/
distribution_t* distribution_new_exponential(size_t num_buckets, double initial_size, double factor);
* ... [custom_bucket_boundaries[array_size - 1], infinity)
* @param array_size - size of array of bucket boundaries. Number of buckets is array_size + 1
* @param custom_buckets_boundaries - array with bucket boundaries. Should be increasing and positive
- * @return pointer to a new distribution or null pointer if parameters are wrong or memory allocation fails
+ * @return - pointer to a new distribution or null pointer if parameters are wrong or memory allocation fails
*/
distribution_t* distribution_new_custom(size_t array_size, double *custom_buckets_boundaries);
+/** add new value to a distribution **/
void distribution_update(distribution_t *dist, double gauge);
+
+/**
+ * @param percent - should be in (0; 100] range
+ * @return - an approximation of percent percentile
+ * (upper bound of such bucket that all less or equal buckets contain more than percent percents of values)
+ * or NAN if parameters are wrong or distribution is empty
+ */
double distribution_percentile(distribution_t *dist, double percent);
+
+/** @return - average of all values in distribution or NAN if distribution is empty */
double distribution_average(distribution_t *dist);
+
+/** @return - pointer to the copy of distribution or null if memory allocation fails */
distribution_t* distribution_clone(distribution_t *dist);
+
+/** destroy the distribution and free memory **/
void distribution_destroy(distribution_t *d);
#endif // COLLECTD_DISTRIBUTION_H